Basic particle effect
Introduction
Ok, this is a basic particle animation. We can use particle to simulate explosions etc.
Below some examples I made :
- Disassemble / assemble : click on the scene for the first animation, click again for the second.
- "Space explosion" : explosion without gravity parameter. Click on the scene.
- Explosion with gravity parameter.
For this tutorial I will define a particle as a "pixel".
We're going to use a linked-list to stock particles in order to gain in performance.
Let's haXe
Let's create the class "Particle" in which we're going to define its attributs.
class Particle
{
/*next represents the next particle (linked-list)*/
public var next:Particle;
/*Our particle will have :
- a color,
- an y position that we're going to vary (y2)
- x and y position
- trajectory variationu
- x and y velocities
*/
public var color:UInt;
public var x:Float;
public var y:Float;
public var y2:Float;
public var variation:Float;
public var xVel:Float;
public var yVel:Float;
public function new(c:UInt)
{
color = c;
}
}

Contact
Follow me