I am wondering if there is an elegant way to script sequential events in GameMaker 2.
In Godot 3.1, it is very easy to chain events together using
yield() and signals. You just start doing something, yield until it emits a signal that it's done, and then continue your code. I am wondering if there is anything similar in GameMaker 2.
In Godot, for example, if i wanted to spawn an explosion cluster which consisted of 10 explosions, each starting 50 milliseconds after each other, I could do something like this.
func create_explosion_cluster(x, y): for x in range(10): create_explosion(x, y) timer = Timer.new() add_child(timer) timer.wait_time = 0.05 timer.start() yield(timer, "timeout") timer.queue_free()
I used this method for complex boss behaviors as well. For example,
func boss_attack(): animation_player.play("intro_to_attack") yield(animation_player, "animation_finished") animation_player.play("attack") for x in range(10): create_projectile(x, y, vector_to_player) timer = Timer.new() add_child(timer) timer.wait_time = 0.05 timer.start() yield(timer, "timeout") timer.queue_free() animation_player.play("outro_to_attack") yield(animation_player, "animation_finished")`
In fact, I use this technique all over the place when I want certain events to follow other events (in transitions, cutscenes, enemy behaviors, etc.)
Is there a way to script sequential events in GameMaker with similar flexibility as you have in Godot?
If there is a general design pattern to solve this kind of problem without
yield(), co-routines, and so on, I'd love to know it.