VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Member Functions | Protected Member Functions | List of all members
Particle Class Reference

Wrapper around a LiquidFun particle. More...

Inheritance diagram for Particle:
WaterParticle

Public Member Functions

 Particle (ParticleLayer *layer)
 Constructs a new Particle. More...
 
bool isDestroyed () const
 Returns whether or not destroy() was already called. More...
 
void destroy ()
 Destroys the associated LiquidFun particle, removing it from the b2ParticleSystem. More...
 

Protected Member Functions

void createNewParticle (const QPointF &position, const QPointF &velocity, const QColor &color)
 Constructs a new LiquidFun particle in the particle system associated with this wrapper, using the specified position, velocity, and color. More...
 
void mapToExistingParticle (int index)
 Associates this Particle with an existing LiquidFun particle in the b2ParticleSystem. More...
 

Detailed Description

Wrapper around a LiquidFun particle.

When createNewParticle() is called, a new LiquidFun particle is spawned, and its user data property is set to this Particle's pointer. This allows the Particle for each LiquidFun particle to be easily retrieved. The LiquidFun particle is destroyed when destroy() is called, or when this object is deleted.

Constructor & Destructor Documentation

Particle::Particle ( ParticleLayer layer)

Constructs a new Particle.

Parameters
layerParticleLayer to associate with

Member Function Documentation

void Particle::createNewParticle ( const QPointF position,
const QPointF velocity,
const QColor color 
)
protected

Constructs a new LiquidFun particle in the particle system associated with this wrapper, using the specified position, velocity, and color.

The new particle's user data will be set to point to this object.

Parameters
positionPosition in world coordinates to spawn the new particle at
velocityInitial velocity of the new particle
colorColor to set for the new particle
void Particle::destroy ( )

Destroys the associated LiquidFun particle, removing it from the b2ParticleSystem.

bool Particle::isDestroyed ( ) const
inline

Returns whether or not destroy() was already called.

void Particle::mapToExistingParticle ( int  index)
protected

Associates this Particle with an existing LiquidFun particle in the b2ParticleSystem.

This does the equivalent of createNewParticle(), without spawning a new particle. Instead it is used to "take over" particles spawned through other means. For example, when spawning groups of particles using b2ParticleSystem::CreateParticleGroup(), multiple particles get created, and can be attached to Particle wrappers using this method.

Parameters
indexIndex of the LiquidFun particle to attach to