Graphical effects are important in most games. Whether it’s just a little sparkle effect or an explosion. Graphical effects can be done using sprites, built-in effects, or the Effects layers. The built-in effects allow for quick prototyping of a game, and can even be used in a finished project. Some examples would be
Visually showing the player that a button has been pressed.
Showing damage when hit by a bullet.
Explosion when an enemy dies.
Effects
A number of basic effects can be created with just one line of code, for example:
This would a create a spark effect at the mouse’s position.
Create an object obj_test and put this code in a Step Event, pop it into a room and test.
The general format used is:
effect_create_below(type,x,y,size,colour);
Note
Effect code does not need to be in a Draw Event, it can be in a Step Event, Key Press Event, etc. which can be very useful!
You’ll see that there are two options: effect_create_above() and effect_create_below(). The above option will draw above it’s default sprite or anything in its Draw Event, while below would draw beneath.
Another example would be that below, add this to your Step Event and test again:
You can also create effects using the Effect Layer. A number of effects are available, with new ones added on a regular basis.
Start a new project, load in the ocean background and set it as a background for a room, as shown in Figure 19-2.
Next, add an Effect Layer between the Instances and Background layers by clicking, as shown in Figure 19-3. The Effect Layer applies to layers below it, so in this case, the effects would be applied to Background and not Instances above it.
Now choose an effect, for example as shown in Figure 19-4.
Have a play around choosing various settings for each effect, for example, as shown in Figure 19-5.
Basic Projects
A)
Set key S & R to change the weather between snow and rain.
B)
Create fireworks in random size and color.
Advance Projects
C)
Use the effects layer to create an underwater scene with wave effects.
D)
Make a system that shakes the room when space is help down.
Useful Functions
Pre-rendered sprite animations can also be used to create some awesome effects, for example, a sprite sheet with explosions, as shown in Figure 19-6.
GameMaker also allows use of a particle system; if you’re feeling adventurous, then look into this.
fx_* functions allow controlling the effects layer whilst your game is running.
Summary
You can now perform basic effects, both in code and using effects layers.