Classes | Functions
Particles

Contains a particle system based on textures. The module also provides several affector and emitter classes. More...

Classes

class  thor::ForceAffector
 Applies a translational acceleration to particles over time. More...
 
class  thor::TorqueAffector
 Applies a rotational acceleration to particles over time. More...
 
class  thor::ScaleAffector
 Scales particles over time. More...
 
class  thor::AnimationAffector
 Affector that animates particles using a function. More...
 
class  thor::EmissionInterface
 Class that connects emitters with their corresponding particle system. More...
 
class  thor::UniversalEmitter
 Class that emits particles with customizable initial conditions. More...
 
class  thor::Particle
 Particle class More...
 
class  thor::ParticleSystem
 Class for particle systems. More...
 

Functions

template<typename Affector >
std::function< void(Particle &, sf::Time)> thor::refAffector (Affector &referenced)
 Creates a functor that references an affector. More...
 
template<typename Emitter >
std::function< void(EmissionInterface &, sf::Time)> thor::refEmitter (Emitter &referenced)
 Creates a functor that references an emitter. More...
 
sf::Time getElapsedLifetime (const Particle &particle)
 Returns the time passed since the particle has been emitted.
 
sf::Time getTotalLifetime (const Particle &particle)
 Returns the total time the particle is alive.
 
sf::Time getRemainingLifetime (const Particle &particle)
 Returns the time left until the particle dies.
 
float getElapsedRatio (const Particle &particle)
 Returns elapsed lifetime / total lifetime.
 
float getRemainingRatio (const Particle &particle)
 Returns remaining lifetime / total lifetime.
 
void abandonParticle (Particle &particle)
 Marks a particle for removal. More...
 

Detailed Description

Contains a particle system based on textures. The module also provides several affector and emitter classes.

Function Documentation

void abandonParticle ( Particle particle)
related

Marks a particle for removal.

This function can be used when the lifetime of particles is not bound to time, but another condition. For example, in a physics simulation, particles may disappear as soon as they hit an object. Calling this function will set the particle's elapsed time to the total lifetime, and the next update of the particle system will remove it.

template<typename Affector >
std::function<void(Particle&, sf::Time)> thor::refAffector ( Affector &  referenced)

Creates a functor that references an affector.

Parameters
referencedAffector functor to reference.

Use this function if you do not want to copy the affector, but reference it, when you pass it to thor::ParticleSystem. This allows you to modify the original object after it has been added, and effects are still visible. However, you are responsible to ensure the lifetime of the referenced object. Example:

// Create affector and particle system
thor::ForceAffector affector(acceleration);
// Add affector to particle system
system.addAffector(thor::refAffector(affector));
// Change affector properties later
affector = ForceAffector(newAcceleration);
template<typename Emitter >
std::function<void(EmissionInterface&, sf::Time)> thor::refEmitter ( Emitter &  referenced)

Creates a functor that references an emitter.

Parameters
referencedEmitter functor to reference.

Use this function if you do not want to copy the emitter, but reference it, when you pass it to thor::ParticleSystem. This allows you to modify the original object after it has been added, and effects are still visible. However, you are responsible to ensure the lifetime of the referenced object. Example:

// Create emitter and particle system
// Add emitter to particle system
system.addEmitter(thor::refEmitter(emitter));
// Change emitter properties later
emitter.setEmissionRate(20);