Пример #1
0
    private void HandleMovement()
    {
        if (Input.IsActionPressed("dpad_left"))
        {
            moveVelocity.x = Utils.Approach(moveVelocity.x, -moveSpeed, moveAcceleration);
            sprite.SetScale(new Vector2(-1.0f, 1.0f));

            if (animationPlayback.IsPlaying())
            {
                animationPlayback.Travel("run");
            }
        }
        else if (Input.IsActionPressed("dpad_right"))
        {
            moveVelocity.x = Utils.Approach(moveVelocity.x, moveSpeed, moveAcceleration);
            sprite.SetScale(new Vector2(1.0f, 1.0f));

            if (animationPlayback.IsPlaying())
            {
                animationPlayback.Travel("run");
            }
        }
        else
        {
            moveVelocity.x = Utils.Approach(moveVelocity.x, 0.0f, moveFriction);

            if (animationPlayback.IsPlaying())
            {
                animationPlayback.Travel("stand");
            }
        }
    }
Пример #2
0
 // Called every frame. 'delta' is the elapsed time since the previous frame.
 public override void _Process(float delta)
 {
     GD.Print(stateMachine.IsPlaying());
 }