Godot Version
Godot_v4.2.1
Question
Hi guys. My question is like in the title I’m struggling making a 2d book closing and opening animation as a pause menu when the button is pressed.
Problem:
Using Animated sprite node or Animation node isn’t the problem the problem here is coding the animation for it to work directly in the game. I could code the sprite for it to appear but I can’t seem to make it identify when to play the closing animation or opening animation and when to stop the closing animation.
here’s my code:
func _process(delta)
if Input.is_action_just_pressed(“Tab”):
$AnimatedSprite2D.play(“book_open”) #“book_open/close” is the Animsprite2D
elif Input.is_action_just_pressed(“Tab”):
$AnimatedSprite2D.play(“book_close”)
(Idk how to end the closing animation even if I turn off the looping button. I’ve already used $AnimatedSprite2D.stop and it doesn’t work)
extra comment:
my code sucks I know I just started a month ago (feel free to criticize me) it’s simple and I’m still learning.
why it’s in process(delta)? I’m only following a tutorial and I can’t seem to make a function for an animation. I won’t tell what tutorial I don’t want the blame to be put on them for my stupidity.
I’ve been struggling with this for a week now, I’ve tried searching but nothing seems to work. if anyone knows a tutorial or a way for this to work. please lend a hand. I’m not quite familiar with coding, I only know the basics of GDScript and that’s it. I’m making my first game and in the process learn coding. (why not just use a simplier way? it’s because it’s part of the theme of my game. I really want it to work and I don’t want to scrape my already planned game). also if you guys know helpful tips on coding feel free to comment it.