![]() |
Angel
A 2D Game Prototyping Engine
|
An Actor that draws and keeps track of drawing a particle system on screen. More...
#include <ParticleActor.h>
Inheritance diagram for ParticleActor:Public Member Functions | |
| ParticleActor () | |
| ~ParticleActor () | |
| virtual void | Update (float dt) |
| virtual void | Render () |
| void | SetParticlesPerSecond (float pps) |
| void | SetSystemLifetime (float lifetime) |
| void | SetParticleLifetime (float lifetime) |
| void | SetSpread (float radians) |
| void | SetEndScale (float scale) |
| void | SetEndColor (Color &color) |
| void | SetSpeedRange (float minSpeed, float maxSpeed) |
| void | SetMinSpeed (float minSpeed) |
| void | SetMaxSpeed (float maxSpeed) |
| void | SetGravity (Vector2 &gravity) |
| void | SetMaxParticles (int maxParticles) |
| virtual const String | GetClassName () |
Protected Attributes | |
| Particle * | _particles |
| int | _maxParticlesAlive |
| int | _numParticlesAlive |
| float | _particlesPerSecond |
| int | _maxParticlesToGenerate |
| float | _generationResidue |
| float | _systemLifetime |
| float | _particleLifetime |
| float | _spreadRadians |
| Color | _endColor |
| float | _minSpeed |
| float | _maxSpeed |
| float | _endScale |
| Vector2 | _gravity |
Friends | |
| class | ParticleActorFactoryDelegate |
Particle systems are a very common feature of most games -- they can be used for effects like fire, smoke, sparklies, etc. A discussion of the general use of particles is beyond the scope of this documentation, but if you're not familiar with the concept, this article by Jeff Lander is a good starting point.
http://www.double.co.nz/dust/col0798.pdf
Definition at line 57 of file ParticleActor.h.
| ParticleActor::ParticleActor | ( | ) |
The default constructor creates a particle system that doesn't really do anything, since its maximum number of particles is 0. You'll need to call the "Set" functions below to make it look purty.
Definition at line 35 of file ParticleActor.cpp.
| ParticleActor::~ParticleActor | ( | ) |
Deletes all the particles this Actor is keeping track of.
Definition at line 60 of file ParticleActor.cpp.
| void ParticleActor::Update | ( | float | dt | ) | [virtual] |
Override of the normal Renderable::Update function. Changes the position and appearance of each individual particle appropriately.
| dt | The amount of time that's elapsed since the beginning of the last frame. |
Reimplemented from Actor.
Definition at line 65 of file ParticleActor.cpp.
| void ParticleActor::Render | ( | ) | [virtual] |
Override of the normal Renderable::Render function. Draws each particle.
Reimplemented from Actor.
Definition at line 174 of file ParticleActor.cpp.
| void ParticleActor::SetParticlesPerSecond | ( | float | pps | ) |
Change the rate at which this system releases particles. Default is 20 particles per second.
| pps | The new release rate in particles per second. |
Definition at line 232 of file ParticleActor.cpp.
| void ParticleActor::SetSystemLifetime | ( | float | lifetime | ) |
Change the system lifetime for this Actor. If the lifetime is set less than or equal to 0.0 (the default), the system will last until it's explicitly removed from the world. Otherwise the system will properly remove and deallocate itself when the elapsed time is up. (Useful for when you just want a burst of particles for a period of time and don't want to set up housekeeping timer.)
| lifetime | The amount of time this system will persist, in seconds. |
Definition at line 241 of file ParticleActor.cpp.
| void ParticleActor::SetParticleLifetime | ( | float | lifetime | ) |
Change the lifetime of each individual particle.
| lifetime | Particle lifetime in seconds |
Definition at line 250 of file ParticleActor.cpp.
| void ParticleActor::SetSpread | ( | float | radians | ) |
Set the angle at which particles will disperse themselves. This affects their intial velocity only. Default is 0.0 (straight line to the right).
| radians | Emission angle in radians |
Definition at line 259 of file ParticleActor.cpp.
| void ParticleActor::SetEndScale | ( | float | scale | ) |
Set the relative size each particle will grow (or shrink) to over its lifetime. The starting size is set with the normal Actor::SetSize function. The ending scale respects the starting aspect ratio.
| scale | The multiplier gradually applied to each particle |
Definition at line 264 of file ParticleActor.cpp.
| void ParticleActor::SetEndColor | ( | Color & | color | ) |
Set the color each particle should be at the end of its life. Use an alpha of 0.0 to have the particles fade out over time. Starting color is set with the normal Actor::SetColor function.
| color | The ending color for each particle in the system. |
Definition at line 269 of file ParticleActor.cpp.
| void ParticleActor::SetSpeedRange | ( | float | minSpeed, |
| float | maxSpeed | ||
| ) |
Set the range of potential initial speeds for the particles. Each particle, at the start of its life, will randomly pick a speed in the given range.
| minSpeed | The speed (in GL units per second) of the slowest particle |
| maxSpeed | The speed (in GL units per second) of the fastest particle |
Definition at line 274 of file ParticleActor.cpp.
| void ParticleActor::SetMinSpeed | ( | float | minSpeed | ) |
Set the lower range of potential initial speeds for the particles.
| minSpeed | The speed (in GL units per second) of the slowest particle |
Definition at line 280 of file ParticleActor.cpp.
| void ParticleActor::SetMaxSpeed | ( | float | maxSpeed | ) |
Set the lower range of potential initial speeds for the particles.
| maxSpeed | The speed (in GL units per second) of the fastest particle |
Definition at line 285 of file ParticleActor.cpp.
| void ParticleActor::SetGravity | ( | Vector2 & | gravity | ) |
Set the vector which will pull the particles in a specific direction at a specified magnitude. The default is (0.0, -4.0).
| gravity | The vector in which the particles should be pulled (magnitude affecting the force of the pull). |
Definition at line 290 of file ParticleActor.cpp.
| void ParticleActor::SetMaxParticles | ( | int | maxParticles | ) |
Set the maximum number of particles this system can keep track of at any one time. Decrease this number if you find you're having performance issues with your particles.
| maxParticles | The maximum number of particles for this system. |
Definition at line 295 of file ParticleActor.cpp.
| virtual const String ParticleActor::GetClassName | ( | ) | [inline, virtual] |
Used by the SetName function to create a basename for this class. Overridden from Actor::GetClassName.
Reimplemented from Actor.
Definition at line 188 of file ParticleActor.h.


1.7.5.1