コード例 #1
0
        public ObjectAnimator CreateNoteAnimation_FadeOnly(Position position)
        {
            const float    TRANSPARENT      = 0;
            const long     DEFAULT_DURATION = 1000;
            DisplayMetrics screenDimensions = Generic.GetScreenDimentions(_currentActivity);
            //TODO: Add string positions as well.

            FretMetrics fretMetrics = GetFretMetrics(position.Fret);
            int         Y_dest      = fretMetrics.GetVerticalCenter() - _noteCircle.Height / 2;
            int         X_dest      = fretMetrics.GetHorizontalCenter() - _noteCircle.Width / 2;

            //Set initial location.
            _noteCircle.SetX(X_dest);
            _noteCircle.SetY(Y_dest);

            ObjectAnimator objAnimFadeOut = ObjectAnimator.OfFloat(_noteCircle, "Alpha", TRANSPARENT);

            objAnimFadeOut.SetDuration(DEFAULT_DURATION);

            objAnimFadeOut.AnimationEnd += (object sender, EventArgs e) =>
            {
                OnNoteGone(this, new EventArgs());
            };

            return(objAnimFadeOut);
        }
コード例 #2
0
        /// <summary>
        /// Animates the note from the bottom to the top, and positions it depending on its fret position.
        /// </summary>
        /// <returns>Returns the animation of this NoteRepresentation.</returns>
        public ObjectAnimator CreateNoteAnimation()
        {
            const float    TRANSPARENT      = 0;
            DisplayMetrics screenDimensions = Generic.GetScreenDimentions(_currentActivity);

            FretMetrics fretMetrics = GetFretMetrics(_note.Position.Fret);

            //TODO: Add string positions as well.

            //Set initial location.
            _noteCircle.SetX(fretMetrics.GetHorizontalCenter() - _noteCircle.Width / 2);
            _noteCircle.SetY(screenDimensions.HeightPixels);

            int Y_dest = fretMetrics.GetVerticalCenter() - _noteCircle.Height / 2;

            ObjectAnimator objAnim = ObjectAnimator.OfFloat(_noteCircle, "Y", Y_dest);

            objAnim.SetDuration((long)_note.Duration);
            objAnim.StartDelay = (long)_note.Delay;

            objAnim.AnimationEnd += (object sender, EventArgs e) =>
            {
                ObjectAnimator objAnimFadeOut = ObjectAnimator.OfFloat(_noteCircle, "Alpha", TRANSPARENT);
                objAnimFadeOut.SetDuration((long)_note.Duration);
                objAnimFadeOut.Start();

                //Start capturing of note's sound input.
                OnNoteArraival(this, new OnNoteArraivalArgs(_note.Hertz));

                objAnimFadeOut.AnimationEnd += (object sender2, EventArgs e2) =>
                {
                    //Note's sound input window closes.
                    OnNoteGone(this, new EventArgs());
                };
            };

            return(objAnim);

            /*PropertyViewAnimator pva = new PropertyViewAnimator(_noteCircle);
             * //Start
             * pva.Animate()
             *  .SetDuration((int)(_note.Duration))
             *  .SetStartDelay((int)(_note.Delay))
             *  .Y(Y_dest_start)
             *  .WithEndAction(new Runnable(() => {
             *      //Start capturing of note's sound input.
             *      //Raise StartNoteCapture event.
             *      pva.Alpha(transparent).WithEndAction(new Runnable(() => {
             *          //Note's sound input window closes.
             *          //Raise EndNoteCapture event.
             *      }));
             *  }));
             * //Dilemma:
             * //Middle and End.
             * //But the animation does not happen here, it happens in AnimatorSet.
             *
             * return pva;*/
        }