Skip to content
Andrew Gleeson edited this page Jan 5, 2022 · 1 revision

Install

  1. Download the latest .yymps here
  2. Install the package by drag+dropping into the IDE, or by navigating to "Tools > Import Local Package".
  3. It should contain a single "Script". Select 'Add All' and then 'Import'.
  4. Sprinkle should now be imported into your project.

Usage

The basic hierarchy is "ParticleSystem > ParticleEmitter > Particles", where "Particles" inherit from a pre-defined "ParticleType".

It's a good idea to set up your ParticleType definitions somewhere first, assuming they will be consistent throughout the project.

:: Custom Script OR Create Event

particleTypes = {
    fire : new ParticleType().alpha(.5,.0).blend(true).color(c_red), // etc.
    smoke : new ParticleType().alpha(.3,.0).color(c_gray), // etc.
}

Then in a Create() event, let's set up a new ParticleSystem with an associated ParticleEmitter.

:: Create Event

// Create Particle System
partSystem = new ParticleSystem();

// Create Emitter (remember to use `.id`)
emitter = new ParticleEmitter(partSystem.id);

In this example, we want to "burst" some fire particles at the mouse position when we click mb_left.

:: Step Event

// Burst particles at mouse position (remember to use `.id`)
if (mouse_check_button_pressed(mb_left)) {
    emitter.position(mouse_x, mouse_y).burst(particleTypes.fire.id, 25);
}

Go ahead and Run(F5) that to see if it works!

That's all you need to start using GameMaker's particle systems - much less than the native method!


One thing to keep in mind - we are responsible for managing memory for these. Forgetting to do so will cause memory leaks in your project.

Fortunately, all we need to worry about is running .destroy() on the ParticleSystem, which should care of most of it.

:: Destroy/Clean Up Event

// Destroying ParticleSystem as it is no longer needed.
partSystem.destroy();

If you are creating new ParticleTypes and no longer need them, then also remember to run .destroy() on those as well.

// Destroying ParticleTypes as they are no longer needed.
with(particleTypes) {
    fire.destroy();
    smoke.destroy();
}

Reference

Refer to the Wiki for a full list of functions to use.

Clone this wiki locally