Sequences allow you to program in a set sequence that can be applied to one or more assets. It can play sounds, move objects, and move and animate sprites. Generally, you’ll program this within the sequence editor rather than using GML.
Moving buttons in for a menu
Creating an effect, for example, when an enemy dies
Animated cut-scenes
Making a sprite rotate, like when collecting a bonus
A boss level enemy movement and attack sequence
Make a complex animation, like a swinging chain/rope
Firing an intricate bullet spread
Applying audio and graphical effects when a player collects an invincibility bonus
Playing several sound effects in a set order
Let’s start by creating a few assets that you’ll use in the example.
Next create a sound snd_bird, and load in a bird sound from the folder From YoYo Games.
We won’t be using left room editor tab for a bit, so you can click the X to close, so you have more space available for setting up your sequence. (Just click a Layout in the top bar, then Reset Layout, and then click any room in the asset tree to get this back.)
Creating a Sequence
You now want to move the time to the end of the sequence; there are a few methods for doing this, like clicking where the numbers are above the orange bar (as in Figure 29-8).
GameMaker will do all the animation needed to start this sprite at the bottom left for time position 0 and move it to the bottom right for time position 300. Press spacebar now and you’ll see it move.
Let’s set up to move up to the top middle of the gray box at the midway point (time 150).
You can now press spacebar again to test.
Let’s make it more interesting by changing the scale of the image as it moves.
Setting a Scale Curve
You can now test by pressing spacebar again.
You can also add audio to a sequence, go to position 150 again by typing it in the time box.
First click in an empty area of the main window, so nothing is selected, then drag over the sound asset you created at the start of this chapter into the main sequence window.
It will now play this sound when the bird reaches the middle of its sequence – being both at the top middle and largest scale.
Setting the loop type not only applies to the sequence preview, it also applies to the sequence when you use it in your game.
You can now drag your sequence from the resources tree onto this layer.
To make positioning your sequence easier, you may want to turn off snapping to position, as shown in Figure 29-19.
An example for this project is in the download resources.
You also add in objects and make them move around in preset sequences, in a similar fashion to moving sprites.
Basic Project
- A)
Make eight stars that start at the center of the room and move outwards and out the room, make the stars increase in size as they do this.
Advance Project
- B)
Make an animated skeleton move from the left to the right, jumping over static boxes as it does so. Play a jumping sound each time it jumps and stop the skeleton’s animation while it is jumping.
Useful Functions
Otherwise, I won’t be providing any functions for Sequences as it is beyond the scope of this book – covering just the basics would require a whole book on its own.
Even with just the basics you’ve learnt in this chapter, you’ll be able to create some pretty awesome effects, cool animations, cutscenes, and more.
Summary
You should now have a basic grasp of Sequences and have an idea of how capable they can be.
We’ve only covered the basics, but sequences are a very capable tool, so feel free to look more into what it has to offer.