ParticleCandy Quick Start Guide

ParticleCandy Quick Start Guide

The details contained on this page are the copyright of
They are duplicated here purely for my own personal use as a licensed user of Particle Candy.  I cannot and will not provide the code for ParticleCandy so please do not ask.  If you wish to try it out please head over to

Include the library

Place the library’s .lua file in the directory of your project and include it with the following command (just place the name of the library within the quotes, without the “.lua” extension) :

Now create some emitters. Emitters can be created and deleted at any time, but it’s a good practice to create them right before your scene starts, re-use them during the game and delete them during scene clean-up:

You can also receive a handle to the created emitter. This handle can then be used to freely position, rotate or move the emitter. An emitter’s handle can be used like any common graphics object. Therefore, you can also place an emitter within a certain group. Principally, all particles of an emitter will be drawn inside the emitter’s parent. So if you put the emitter into a display group, it’s particles will be drawn inside this group only.
Important note:  If you store an emitter’s handle, you must set this reference to the emitter to “nil” before you delete the emitter. Otherwise, it cannot be garbage collected and will remain in memory! So be careful when storing emitter handles on your own!

Creating a particle type

A particle type describes how particles behave, so a particle type contains all relevant properties of a certain kind of particle. You can create as many different particle types and attach as many of them to an emitter as you like. For a fire effect, for example, you would create one particle type for the smoke, another one for the flames and maybe a third one to show some sparks flying around. Attach them to an emitter then and you are ready to go.

Attaching the particle types to the emitter

Now we feed the emitters with the particle types you just created. You can attach as many particle types to an emitter as you like and define an emission rate, emission duration and a delay for each attached particle type (repeat this with each particle type you’d like to attach to the emitter):

Trigger the emitter

Now your emitters are charged and can be triggered (or stopped) at any time within the game. The particles will be drawn in the emitter’s parent group (if there is one) and will be shot in the direction where the emitter points (remember, you can freely move and rotate the emitter -you can also attach it to the exhaust of your space ship, for example).

Important note:  In order to update and animate your particles, don’t forget to call the library’s Update() function once every frame (within your main loop).


After your main game loop finished, simply remove all created emitters, particle types and particles on screen by using:

Important note:  If you stored any emitter handles using GetEmitter() you must set these references to the emitters to “nil” before you delete the emitters otherwise they cannot be garbage collected and will remain in memory, so be careful when storing emitter handles on your own.


And this concludes the quick start guide.

Comments are closed.

Pin It on Pinterest