We’d love to hear from you. Whether you have a question that you’d like us to answer as part of our FAQ,  you’ve identified something that just doesn’t quite look right in one of our tutorials, you have a business opportunity or for any other reason, please use this simple form to contact us.

We’ll do our best to provide a prompt response.

Like what you see?...pass it on!

Particles

Now let’s add a little graphical pizzazz! A particle system is in the simplest terms, a game object that coordinates several other game objects. In 2D that generally means it creates dozens, hundreds or even thousands of lightweight graphic objects, used to create all kinds of special effects, like fire, smoke, water and more. Today we will be adding a simple ghosting effect to our character because…. Reasons!

First we need to create the particle system. Simply right click the player folder, select New->Particle Fx

Creating a Particle System

Now name your new particle system.

Pasted Graphic 63

This will create a new game object with a child emitter.

Particle Emitter

This is the source of our particles. You have several different options for the emitter (think hose) where the particles will come from, but I will stick with the default cone. Now we need to pick a “particle” or image source to use for each image in the system. Select the player atlas and run animation for the particle Image and Animation respectively.

Pasted Graphic 65

There are an absolute ton of different parameters you can control about how the particles will be created and how long they last, how fast they are “sprayed” and more. In this case, I simply set red and green to 0, blue to full on alpha (transparency) down to 0.3 or 30%.

Pasted Graphic 66

Obviously, you could play for hours getting a particle system right. Notice the graphic to the left of the edit boxes? This enables you to edit the life cycle of this attribute using the curve editor, giving you fine-tune control over this property over time. Click that button and switch to the editor and you will see:

Curve Editor

This editor gives you fine-tuned control over the alpha value of the particle across its life span. Notice the left hand margin shows values from 10 to -10, while the other axis represents the particles total life span. By moving points around, you can fine-tune various values over time.

You can preview your particle system in action at any time by highlighting the view window and hitting the spacebar.

Pasted Graphic 68

Now that we’ve created our Particle fx, switch over to player.collection, and add the particle system to the player’s game object, by right clicking it and selecting Add Component File and selecting the newly created particle system. In the end, your player game object should look like:

Player Game Object

Finally, we need to tell the particle system to start playing when our player game object is created. Edit the init() function to the following:

function init(self)
	msg.post(".","acquire_input_focus")
	self.runSpeed = 50
	self.curAnim = "idle"
	msg.post("#sprite", "play_animation", { id=hash("idle") })
	self.speed = vmath.vector3()
	particlefx.play("#playerParticle")
end

 

Now when we run our game:

Blue ghostly steam!

Playing Music<<PreviousTable of ContentsNext>>Adding Physics

Like what you see?...pass it on!

script ends --->