fix: add stop for animatedSprite2D;
This commit is contained in:
@@ -11,17 +11,16 @@ func _ready() -> void:
|
|||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
var move_vector: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
var move_vector: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||||
velocity = move_vector * move_speed
|
velocity = move_vector * move_speed
|
||||||
|
if velocity == Vector2(0, 0):
|
||||||
|
$AnimatedSprite2D.stop()
|
||||||
if velocity.x > 0:
|
if velocity.x > 0:
|
||||||
$AnimatedSprite2D.play("move_right")
|
$AnimatedSprite2D.play("move_right")
|
||||||
print(velocity)
|
|
||||||
if velocity.x < 0:
|
if velocity.x < 0:
|
||||||
$AnimatedSprite2D.play("move_left")
|
$AnimatedSprite2D.play("move_left")
|
||||||
print(velocity)
|
|
||||||
if velocity.y > 0:
|
if velocity.y > 0:
|
||||||
$AnimatedSprite2D.play("move_down")
|
$AnimatedSprite2D.play("move_down")
|
||||||
print(velocity)
|
|
||||||
if velocity.y < 0:
|
if velocity.y < 0:
|
||||||
$AnimatedSprite2D.play("move_up")
|
$AnimatedSprite2D.play("move_up")
|
||||||
print(velocity)
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|||||||
Reference in New Issue
Block a user