mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 20:25:54 +00:00
fragola and bullet
This commit is contained in:
parent
c9b3164362
commit
b7fb003b70
14 changed files with 383 additions and 53 deletions
|
|
@ -5,9 +5,9 @@ public partial class PlayerMovement : CharacterBody2D
|
|||
{
|
||||
[Export]
|
||||
public int Speed { get; set; } = 400;
|
||||
|
||||
|
||||
private AnimatedSprite2D _animatedSprite;
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
|
||||
|
|
@ -25,6 +25,43 @@ public partial class PlayerMovement : CharacterBody2D
|
|||
}
|
||||
}*/
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
SetAnimation();
|
||||
}
|
||||
|
||||
private void SetAnimation()
|
||||
{
|
||||
|
||||
if (Velocity.X == 0 && Velocity.Y == 0)
|
||||
{
|
||||
_animatedSprite.SpeedScale = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_animatedSprite.SpeedScale = 1;
|
||||
}
|
||||
|
||||
if (Velocity.X > 0)
|
||||
{
|
||||
_animatedSprite.Play("walk_right");
|
||||
}
|
||||
else if (Velocity.X < 0)
|
||||
{
|
||||
_animatedSprite.Play("walk_left");
|
||||
}
|
||||
else if (Velocity.Y > 0)
|
||||
{
|
||||
_animatedSprite.Play("walk_down");
|
||||
}
|
||||
else if (Velocity.Y < 0)
|
||||
{
|
||||
_animatedSprite.Play("walk_up");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Vector2 GetInput()
|
||||
{
|
||||
return Input.GetVector("left", "right", "up", "down");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue