Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Elginive |
Hey everyone. I’m really new to coding- I’ve been going crazy trying to figure this out, so if someone could please help me, I would greatly appreciate it. I am able to get my sprite to run around on the screen no problem- but the animation will keep playing without the anim.stop() (I’ve also tried anim.set_frame(0) )
But when I call this, the attack input will only play the 1 frame. I’ve tried using signals, but I don’t think I fully understand them, because that hasn’t fixed the issue for me. I got the idea to create an idle animation of sorts, but I am working with a sky view, so I either have to make an idle animation for each direction, or set a frame for each direction.
any guidance would be super helpful, thanks
func _process(delta):
var velocity = Vector2()
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
$Link.play ("up")
$Link.flip_h = velocity.x < 0
if Input.is_action_pressed("ui_down"):
velocity.y += 1
$Link.play ("down")
$Link.flip_h = velocity.x < 0
if Input.is_action_pressed("ui_left"):
velocity.x -= 1
$Link.play ("right")
$Link.flip_v = false
$Link.flip_h = velocity.x < 0
if Input.is_action_pressed("ui_right"):
velocity.x += 1
$Link.play ("right")
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$Link.play()
else:
$Link.play("idle")
position += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.y, 0, screensize.y)