Particle Systems

This section deals with setting up, maintaining and destroying particle systems.

Before you can create particles you need to create a particle system. This is a "container" where you place your particles and emitters (if you need them) ready for use, and you can put as many or as few particles into any one system as you think necessary, and you can have as many systems as you think necessary too. However, it is always better to keep this number as small as possible due to the fact that each system, emitter and particle takes up memory and having too many of them may slow your game down or cause problems. For example, if you need some effects to appear above instances, and other effects to appear beneath instances, you would create two systems and set their depths to get the desired effect, with all particles that are added to each system being drawn at the depth you specify.

System Functions

Since a particle system is a dynamically created resource, you must create it and store the returned index in a variable to reference the system in all further function calls, and it is very important that you also destroy the system when it is no longer needed or else you will have a memory leak that will slow down and eventually crash your game. It is also worth noting that particle systems will live on forever after they are created, even if the index is no longer stored. So even if you change room or restart the game, the systems and the particles will remain, and be visible, in all further rooms so you better make sure you destroy them once you no longer need them.

The basic functions for setting up a particle system are listed below:

  1. part_system_exists
  2. part_system_create
  3. part_system_clear
  4. part_system_depth
  5. part_system_position
  6. part_system_destroy
  7. part_particles_clear
  8. part_particles_count

Particle System Drawing

Once particles are added to a particle system and then burst or streamed into the room, they are normally automatically updated each step and drawn based on the parameters that you have used to define them. However it can sometimes be necessary to control when and how the system is updated as well as how the system should be drawn, and for that GameMaker: Studio provides the following functions:

  1. part_system_automatic_update
  2. part_system_automatic_draw
  3. part_system_update
  4. part_system_drawit
  5. part_system_draw_order

Creating Particles Directly

Normally you would use particle emitters to burst or stream particles from an area, but in many cases these are not necessary and it is actually better to just create the particles directly using the following functions:

  1. part_particles_create
  2. part_particles_create_colour


Back: Particles
© Copyright YoYo Games Ltd. 2018 All Rights Reserved