Emits particles towards a specified target zone. More...
Public Types | |
typedef std::tr1::shared_ptr < TargetEmitter > | Ptr |
Shared pointer type referring to TargetEmitter objects. | |
typedef MovedPtr< Zone, VirtualClone > | ZonePtr |
Movable smart pointer to Zone derivates. | |
Static Public Member Functions | |
static Ptr | Create (float particlesPerSecond, sf::Time particleLifetime) |
Creates an emitter that emits particles towards a target zone. | |
Public Member Functions | |
TargetEmitter (float particlesPerSecond, sf::Time particleLifetime) | |
Constructor. | |
virtual void | Emit (Adder &system, sf::Time dt) |
Emits particles into a particle system. | |
void | SetTargetZone (Emitter::ZonePtr zone) |
Sets the zone towards which particles are emitted. | |
Zone & | GetTargetZone () |
Returns the zone towards which the particles are emitted. | |
const Zone & | GetTargetZone () const |
Returns the zone towards which the particles are emitted (const overload). | |
void | SetParticleSpeed (float speed) |
Sets the speed of the emitted particles. | |
float | GetParticleSpeed () const |
Returns the speed of the emitted particles. | |
void | SetEmissionZone (Emitter::ZonePtr zone) |
Sets the zone inside which particles are created. | |
Zone & | GetEmissionZone () |
Returns the zone inside which particles are created. | |
const Zone & | GetEmissionZone () const |
Returns the zone inside which particles are created (const overload). | |
void | SetEmissionRate (float particlesPerSecond) |
Sets the particle emission rate. | |
float | GetEmissionRate () const |
Returns the particle emission rate. | |
void | SetParticleScale (sf::Vector2f scale) |
Sets the initial particle scale. | |
sf::Vector2f | GetParticleScale () const |
Returns the initial particle velocity. | |
void | SetParticleColor (const sf::Color &color) |
Sets the initial particle color. | |
const sf::Color & | GetParticleColor () const |
Returns the initial particle color. | |
void | SetParticleLifetime (sf::Time lifetime) |
Sets the lifetime (time between emission and death) of the particle. | |
sf::Time | GetParticleLifetime () const |
Returns the lifetime (time between emission and death) of the particle. | |
Protected Member Functions | |
unsigned int | ComputeNbParticles (sf::Time dt) |
Helper function for emission: Computes how many particles should be emitted in this frame. | |
Particle | CreateParticlePrototype () const |
Creates a prototype of a particle. |
Emits particles towards a specified target zone.
typedef MovedPtr<Zone, VirtualClone> thor::Emitter::ZonePtr [inherited] |
Movable smart pointer to Zone derivates.
Is used to pass polymorphic zones around. Note that this pointer doesn't have shared ownership semantics, it rather transfers ownership when copied. To create a copy, you can use thor::Copy().
thor::TargetEmitter::TargetEmitter | ( | float | particlesPerSecond, |
sf::Time | particleLifetime | ||
) |
Constructor.
particlesPerSecond | How many particles are emitted in 1 second. The type is not integral to allow more flexibility (e.g. 0.5 yields one particle every 2 seconds). |
particleLifetime | How long the particles live until they are removed. |
unsigned int thor::Emitter::ComputeNbParticles | ( | sf::Time | dt | ) | [protected, inherited] |
Helper function for emission: Computes how many particles should be emitted in this frame.
Saves the user from calculations, takes care of too short times to emit particles. This function shall be called exactly once each frame.
dt | Frame time. |
static Ptr thor::TargetEmitter::Create | ( | float | particlesPerSecond, |
sf::Time | particleLifetime | ||
) | [static] |
Creates an emitter that emits particles towards a target zone.
particlesPerSecond | How many particles are emitted in 1 second. The type is not integral to allow more flexibility (e.g. 0.5 yields one particle every 2 seconds). |
particleLifetime | How long the particles live until they are removed. |
Particle thor::Emitter::CreateParticlePrototype | ( | ) | const [protected, inherited] |
Creates a prototype of a particle.
Applies the initial particle settings (position, rotation, scale, color, lifetime).
virtual void thor::TargetEmitter::Emit | ( | Adder & | system, |
sf::Time | dt | ||
) | [virtual] |
Emits particles into a particle system.
Override this method in your emitter class to implement your own functionality. If your emitter does only emit the particles in a different area, you should have a look at RandomOffset().
system | Indirection to the particle system that stores the particles. |
dt | Time interval during which particles are emitted. |
Implements thor::Emitter.
float thor::Emitter::GetEmissionRate | ( | ) | const [inherited] |
Returns the particle emission rate.
Zone& thor::Emitter::GetEmissionZone | ( | ) | [inherited] |
Returns the zone inside which particles are created.
const Zone& thor::Emitter::GetEmissionZone | ( | ) | const [inherited] |
Returns the zone inside which particles are created (const overload).
float thor::TargetEmitter::GetParticleSpeed | ( | ) | const |
Returns the speed of the emitted particles.
Returns the zone towards which the particles are emitted.
const Zone& thor::TargetEmitter::GetTargetZone | ( | ) | const |
Returns the zone towards which the particles are emitted (const overload).
void thor::Emitter::SetEmissionRate | ( | float | particlesPerSecond | ) | [inherited] |
Sets the particle emission rate.
particlesPerSecond | How many particles are emitted in 1 second. The type is not integral to allow more flexibility (e.g. 0.5 yields one particle every 2 seconds). |
void thor::Emitter::SetEmissionZone | ( | Emitter::ZonePtr | zone | ) | [inherited] |
Sets the zone inside which particles are created.
zone | MovedPtr<Zone, VirtualClone> to concrete zone object. |
void thor::TargetEmitter::SetParticleSpeed | ( | float | speed | ) |
Sets the speed of the emitted particles.
speed | Particle speed. If this value is negative, the particles are emitted away from the target zone (that is, the target zone works repulsively). |
void thor::TargetEmitter::SetTargetZone | ( | Emitter::ZonePtr | zone | ) |
Sets the zone towards which particles are emitted.
zone | MovedPtr<Zone, VirtualClone> to concrete zone object. Every time a particle is emitted, a random point in the target zone is chosen, and the particle is accelerated towards that point. |