Exemplo n.º 1
0
        private void AnimateWalk(KinematicBody2D host)
        {
            AnimationPlayer animPlayer = host.GetNode <AnimationPlayer>("AnimationPlayer");

            Sprite     torch      = host.GetNode <Sprite>("Torch");
            Position2D torchLeft  = host.GetNode <Position2D>("TorchLeft");
            Position2D torchRight = host.GetNode <Position2D>("TorchRight");

            Vector2 playerToMouse = host.GetGlobalMousePosition() - host.GlobalPosition;

            if (playerToMouse.x > 0 && playerToMouse.y > -5)
            {
                animPlayer.Play("right");
                torch.Position        = torchRight.Position;
                torch.RotationDegrees = 25;
            }
            else if (playerToMouse.x < 0 && playerToMouse.y > -5)
            {
                animPlayer.Play("left");
                torch.Position        = torchLeft.Position;
                torch.RotationDegrees = -25;
            }
            else if (playerToMouse.x > 0 && playerToMouse.y <= -5)
            {
                animPlayer.Play("up_right");
                torch.Position        = torchRight.Position;
                torch.RotationDegrees = 25;
            }
            else if (playerToMouse.x < 0 && playerToMouse.y <= -5)
            {
                animPlayer.Play("up_left");
                torch.Position        = torchLeft.Position;
                torch.RotationDegrees = -25;
            }
        }