With the latest 2.3 update GameMaker has released a super useful new resource called a sequence. This lets you chain and layer objects and animations to create a cool looking…well…sequences.
For me, a really easy win for sequences was to add one after one of the bosses in my game dies. I had already implemented something in code for a previous boss and although the final result looks pretty good. It took a lot of trial and error to be able to do it in code. You can see below I have a number of alarms to control timings as well as a collision event when it hits the ground to trigger more explosions.
To be able to replicate a similar death animation using sequences only requires two lines of code!
var seq = layer_sequence_create("Blocks_Layer", x, y, sq_Boss2_Death); layer_sequence_play(seq);
The sequence itself is created in the gamemaker UI. You can drag existing sprites onto the sheet and play around with timings. In this cases it allows you to stack explosions on top of one another to create a cool effect .The other thing I’m doing here is a a simple key frame positional move with the main boss sprite as it losses power. You can change a number of different properties such as rotation, scale, colour and position over time. As I said you could do this in code but this shortens the feedback loop and allows you to experiment a bit more freely with different effects.
When you want to trigger the animation you would do something like the below:
- Create Sequence (same x,y alignment to the boss object)
- Play Sequence
- Destroy / Hide original boss object
And this is the final result after the boss is dead and the sequence is triggered within the room!
There’s some really great tutorials out there on sequences, but give it a go it’s really easy to get some quick wins.