So I’m making a sort of tiny ‘escape room’ 2d minigame, and while I’ve made a sprite clickable, I need to change it to be +1 frame every single time I click it, since it’s a 1-9 number lock, functionally.
I’ve tried about 5-6 different ways to make this happen, and while I kinda understand why the code I have doesn’t work, I can’t seem to understand what I do need to put in. For context, here’s the last try I had (although I don’t have the other five to show. I did look through the documentation already to try and find something to help, and I found what I have now from it, although if someone could point out if I missed something that will fix this, please do!! I’m very new to reading documentation lol)
var clickable: bool = false
@onready var animated_sprite = $"."
@onready var current_frame = animated_sprite.get_frame()
func _process(delta: float) -> void:
slot_changable()
func slot_changable():
if clickable:
if Input.is_action_just_pressed("clicked"):
print("mouseclicked")
current_frame +1
clickable is getting called. But when I ran this, it gave me absolutely no errors. What did I do wrong? Would I need to make a separate animation for each number switch? I just thought this would be easier, less ‘the same thing every time’ if I could just put in a +1 sprite frame each time i clicked. Is that not possible or am i just doing it very wrong lol?
dragonforge is correct, to build on this you should get a warning along the lines of “this statement has no effect”, because Godot does the math of “current_frame + 1” and throws the answer away, rather than storing it back into current_frame. Make sure to check your script warnings!