The particle engine inside of GameBuilder Studio (GBs) is essentially just another renderer on an entity. Before you can use the Particle renderer you will need to create a particle effect in one of the supported visual particle editors. Either Particle Designer (mac only) or One Designs' browser based editor. These editors will export a .pex file which is just an xml file with all of the property values that you defined to make up your particle effect. Pair that .pex data file with a particle texture/image file and import into GBs. Particle settings can not be edited currently in GBs but this may change in a future update.
Once imported into GBs you will notice a new Particle asset and if you drop that asset onto your scene a purple circle with a black line indicating the direction of the emitter should appear. The position of a Particle renderer is tied to the position of the emitter which spawns the individual particles. allows you to do powerful things like tie an emitter to the position of a bone in a Spine animation or any object with a spatial.
Defining The Texture File
The texture file name needs to be included in the .pex file like in the image above.
Using Animated Particles
Select the Use Animated Particle checkbox and choose the sprite sheet and the start and end frame of the animation sequence. The frames in the sprite sheet need to be in order.
Manually Adding Animated Particle Settings To The Particle Data File
The particle animation settings can be defined in the ".pex" particle data file ahead of time or in the editor. If you want to do it ahead of time add an "animation" xml entry like in the image above. Remove any
The animation xml node properties:
- isAnimated - Enables animated particles in the particle engine. This value must be 1.
- atlas - Defines the Texture Packer JSON sprite sheet data file that will be used to pull the animation frames from.
- loops - How many times should the animation loop.
- firstFrame - Specify the name of the frame to start with excluding the file extension.
- lastFrame - Specify the name of the frame to end with excluding the file extension.
- randomStartFrames - Allows the particle engine to select a random frame between the start and end frames.
**Note: Make sure that your sprite sheet is sorted by name with the frames laid out in sequence so that the correct animation frames are pulled by the Particle renderer.
Exporting Particle Data From Particle Designer
When exporting from Particle Designer make sure that Embed and Zip are unchecked and Flip Y is selected. Note that only one emitter per particle data file is supported by the Particle Engine in GBs.
Make sure the PEX export type is selected when exporting.
The Particle Emitter Action
There is a Particle action that also comes with the new particle integration that allows you to start (with a time limit), stop, pause, and resume a particle emitter. You may want to uncheck "Auto Start Emitter" on the Particle renderer initially and then start emitting at some point during the game. Just select a Particle Renderer and select the action type.
A Couple Of Optimization Tips
There are a couple ways to optimize the performance of the Particle renderer.
- Try to keep particles within the same scene layer. Particles on the same scene layer are automatically batched when uploaded to the GPU.
- Try to include your particle texture in a shared sprite sheet. Event if you are using one texture for your particle system, turn on animated particles and set the start and end frames to the same frame from the sprite sheet.
- If you have an idea of the total amount of particles your entire game will need in any given level then set the pool size to fixed in the Global Particle Settings section and reduce the particle pool size to the max that you will need.
Next on this topic: "Advance Particle Settings & Changing Properties At Runtime " coming soon...