Archive for the ‘particles’ Category

First steps with Flint Particles

Friday, January 16th, 2009

I’ve been meaning for a while to have a look at Flint and so here are my first steps with it.

First off, I like the way it is arranged. It is incredibly modular. Whilst this probably has implications as far as optimisation (although it seems to handle a whole load of particles pretty nicely), it does mean that any kind of particle system can be plugged together easily.

There are 2 basic objects that need to be instantiated – an emitter and a renderer. There are a few different types of renderer, for different types – Bitmap, DisplayObject and Pixel.

Once you have your emitter created, then the behaviour is adjusted by adding 4 things.

Initialisers.
These are used when a particle is created, so things like colour, mass, size, image to use etc.

Actions.
These are applied to the particle every frame. Things like gravity, collisions etc.

Zones
This an area of the screen, commonly a point, line, rectangle or circle. Zones can be used for some initialisers, for example position and velocity. A Zone used for position will be used to randomly place a particle in that area. The velocity zone creates the velocity based on the time taken for the particle to travel from [0,0] to the randomly selected point. Zones can also be used as actions. For example, a DeathZone is an area that removes particles that enter (or leave) it, and a Jet zone is one that adds a velocity to the particle if it is inside.

Activities
These modify the behaviour of the emitter every frame, for example making it follow the mouse or rotating.

Most of these have a 2D and 3D counterpart.

Right. Enough explanation. Here’s the first experiment:
(Please note there is a bug (in my code) that occasionally comes up where the particles are duplicated endlessly. You have been warned!) This has now been fixed :)
(more…)