Ejemplo n.º 1
0
        private void MoveObjectUpdate()
        {
            // get duration
            if (moveStep == 0)
            {
                Move();
                totalMoveDuration = Time.time + settings.moveDuration;
                moveStep          = 1;
            }

            // move the object
            else if (moveStep == 1)
            {
                if (Time.time >= totalMoveDuration)
                {
                    moveStep = 2;
                }
                else
                {
                    // x = horiz movement, y = vertical movement
                    settings.ComputeVelocityP(speed);
                    settings.AnimateCharacterP();
                    settings.MoveCharacterP();
                }
            }

            // stop moving
            else if (moveStep == 2)
            {
                settings.ComputeVelocityP(new Vector2(0, 0));
                settings.AnimateCharacterP();
                settings.MoveCharacterP();
                if (settings.velocity == new Vector2(0, 0))
                {
                    settings.AnimateCharacterStopP();
                    jumpHeight = 0;
                    moveStep   = 0;
                    enabled    = false;
                }
            }
        }
Ejemplo n.º 2
0
 // compute horizontal velocity, compute jump velocity, animate character
 void Update()
 {
     settings.ComputeVelocityP();
     settings.AnimateCharacterP();
 }