Hey folks!
I've created a Platform Scene & a Button Scene and I connected different buttons to different platforms so that, once the button is pressed, the animation on the platform starts or pauses accordingly.
The thing is I can't help but think there is a better way than the one I did.
Right now, each instance of the button sends a signal and then in GDScript I decide what animation plays:
class_name grassPlatform
extends AnimatableBody2D
func _on_button_lamp_toggled(lamp_on: bool) -> void:
if (lamp_on == true):
$AnimationPlayer.play("left_and_right")
else:
$AnimationPlayer.pause()
func _on_button_2_lamp_toggled(lamp_on: bool) -> void:
if (lamp_on == true):
$AnimationPlayer.play("up_and_down")
else:
$AnimationPlayer.pause()
Isn't there a more modular and scalable way to achieve this?
Thanks in advance!
