Time for action — spawning an explosion
- Add the method
SpawnExplosion
to the engine
class. The parameters are the number of particles and their position. - Set the default layer to
g.layerGFX
. - Start a FOR loop as a counter ranging from
1
to amount
. - Create a new particle object.
- Set its scale, angle, spin, and speed randomly.
- Play the explosion sound.
- Create an object timer, so that the particles will be removed after a random time. The timer ID is
g.tmObjRemove
. - Close the FOR statement and the method.
This new method will spawn some particles that will be deleted via a timer.
Tick tock… acting on object timer events
Treasure Chest has two situations where a timer is set, and we need to act on it:
- When the title screen is shown
- When a particle is spawned
..................Content has been hidden....................
You can't read the all page of ebook, please click
here login for view all page.