Mana
|
A particle spawned by a ParticleEmitter. More...
#include <particle.h>
Public Types | |
enum | AliveStatus { ALIVE = 0 , DEAD_TIMEOUT = 1 , DEAD_FLOOR = 2 , DEAD_SKY = 4 , DEAD_IMPACT = 8 , DEAD_OTHER = 16 , DEAD_LONG_AGO = 128 } |
Public Member Functions | |
Particle (Map *map) | |
Constructor. | |
~Particle () override | |
void | clear () |
Deletes all child particles and emitters. | |
virtual bool | update () |
Updates particle position, returns false when the particle should be deleted. | |
bool | draw (Graphics *graphics, int offsetX, int offsetY) const override |
Draws the particle image. | |
bool | drawnWhenBehind () const override |
Do not draw particles when behind other objects. | |
Particle * | createChild () |
Creates a blank particle as a child of the current particle Useful for creating target particles. | |
Particle * | addEffect (const std::string &particleEffectFile, int pixelX, int pixelY, int rotation=0) |
Creates a child particle that hosts some emitters described in the particleEffectFile. | |
Particle * | addTextSplashEffect (const std::string &text, int x, int y, const gcn::Color *color, gcn::Font *font, bool outline=false) |
Creates a standalone text particle. | |
Particle * | addTextRiseFadeOutEffect (const std::string &text, int x, int y, const gcn::Color *color, gcn::Font *font, bool outline=false) |
Creates a standalone text particle. | |
void | addEmitter (ParticleEmitter *emitter) |
Adds an emitter to the particle. | |
void | moveTo (const Vector &pos) |
Sets the position in 3 dimensional space in pixels relative to map. | |
void | moveTo (float x, float y) |
Sets the position in 2 dimensional space in pixels relative to map. | |
void | moveBy (const Vector &change) |
Changes the particle position relative. | |
void | setLifetime (int lifetime) |
Sets the time in game ticks until the particle is destroyed. | |
void | setFadeOut (int fadeOut) |
Sets the age of the pixel in game ticks where the particle has faded in completely. | |
void | setFadeIn (int fadeIn) |
Sets the remaining particle lifetime where the particle starts to fade out. | |
void | setVelocity (float x, float y, float z) |
Sets the current velocity in 3 dimensional space. | |
void | setGravity (float gravity) |
Sets the downward acceleration. | |
void | setRandomness (int r) |
Sets the ammount of random vector changes. | |
void | setBounce (float bouncieness) |
Sets the ammount of velocity particles retain after hitting the ground. | |
void | setFollow (bool follow) |
Sets the flag if the particle is supposed to be moved by its parent. | |
bool | doesFollow () const |
Gets the flag if the particle is supposed to be moved by its parent. | |
void | setDestination (Particle *target, float accel, float moment) |
Makes the particle move toward another particle with a given acceleration and momentum. | |
void | setDieDistance (float dist) |
Sets the distance in pixel the particle can come near the target particle before it is destroyed. | |
void | adjustEmitterSize (int w, int h) |
Changes the size of the emitters so that the effect fills a rectangle of this size. | |
void | setAllowSizeAdjust (bool adjust) |
bool | isAlive () const |
bool | isExtinct () const |
Determines whether the particle and its children are all dead. | |
void | kill () |
Manually marks the particle for deletion. | |
void | disableAutoDelete () |
After calling this function the particle will only request deletion when kill() is called. | |
float | getAlpha () const override |
Returns the current alpha value used to draw the actor. | |
void | setAlpha (float alpha) override |
Sets the alpha value used to draw the actor. | |
virtual void | setDeathEffect (const std::string &effectFile, char conditions) |
![]() | |
Actor () | |
virtual | ~Actor () |
const Vector & | getPosition () const |
Returns the pixel position of this actor. | |
virtual void | setPosition (const Vector &pos) |
Sets the pixel position of this actor. | |
int | getPixelX () const |
Returns the pixels X coordinate of the actor. | |
int | getPixelY () const |
Returns the pixel Y coordinate of the actor. | |
virtual int | getDrawOrder () const |
Returns the pixel Y coordinate that the actor should be drawn at. | |
virtual int | getTileX () const |
Returns the x coordinate in tiles of the actor. | |
virtual int | getTileY () const |
Returns the y coordinate in tiles of the actor. | |
virtual void | setMap (Map *map) |
Map * | getMap () const |
Static Public Member Functions | |
static void | setupEngine () |
Gives a particle the properties of an engine root particle and loads the particle-related config settings. | |
Static Public Attributes | |
static const float | PARTICLE_SKY = 800.0f |
Maximum Z position of particles. | |
static int | fastPhysics = 0 |
Mode of squareroot calculation. | |
static int | particleCount = 0 |
Current number of particles. | |
static int | maxCount = 0 |
Maximum number of particles. | |
static int | emitterSkip = 1 |
Duration of pause between two emitter updates in ticks. | |
static bool | enabled = true |
true when non-crucial particle effects are disabled | |
Protected Member Functions | |
float | getCurrentAlpha () const |
Calculates the current alpha transparency taking current fade status into account. | |
Protected Attributes | |
float | mAlpha = 1.0f |
Opacity of the graphical representation of the particle. | |
int | mLifetimeLeft = -1 |
Lifetime left in game ticks. | |
int | mLifetimePast = 0 |
Age of the particle in game ticks. | |
int | mFadeOut = 0 |
Lifetime in game ticks left where fading out begins. | |
int | mFadeIn = 0 |
Age in game ticks where fading in is finished. | |
Vector | mVelocity |
Speed in pixels per game-tick. | |
![]() | |
Map * | mMap = nullptr |
Vector | mPos |
Position in pixels relative to map. | |
Private Attributes | |
AliveStatus | mAlive = ALIVE |
Is the particle supposed to be drawn and updated? | |
bool | mAutoDelete = true |
May the particle request its deletion by the parent particle? | |
Emitters | mChildEmitters |
List of child emitters. | |
Particles | mChildParticles |
List of particles controlled by this particle. | |
bool | mAllowSizeAdjust = false |
Can the effect size be adjusted by the object props in the map file? | |
std::string | mDeathEffect |
Particle effect file to be spawned when the particle dies. | |
char | mDeathEffectConditions = 0 |
Bitfield of death conditions which trigger spawning of the death particle. | |
float | mGravity = 0.0f |
Downward acceleration in pixels per game-tick. | |
int | mRandomness = 0 |
Ammount of random vector change. | |
float | mBounce = 0.0f |
How much the particle bounces off when hitting the ground. | |
bool | mFollow = false |
is this particle moved when its parent particle moves? | |
Particle * | mTarget = nullptr |
The particle that attracts this particle. | |
float | mAcceleration = 0.0f |
Acceleration towards the target particle in pixels per game-tick. | |
float | mInvDieDistance = -1.0f |
Distance in pixels from the target particle that causes the destruction of the particle. | |
float | mMomentum = 1.0f |
How much speed the particle retains after each game tick. | |
A particle spawned by a ParticleEmitter.
Definition at line 41 of file particle.h.
Enumerator | |
---|---|
ALIVE | |
DEAD_TIMEOUT | |
DEAD_FLOOR | |
DEAD_SKY | |
DEAD_IMPACT | |
DEAD_OTHER | |
DEAD_LONG_AGO |
Definition at line 44 of file particle.h.
Particle::Particle | ( | Map * | map | ) |
Constructor.
map | the map this particle will add itself to, may be NULL |
Definition at line 57 of file particle.cpp.
|
override |
Definition at line 63 of file particle.cpp.
Particle * Particle::addEffect | ( | const std::string & | particleEffectFile, |
int | pixelX, | ||
int | pixelY, | ||
int | rotation = 0 |
||
) |
Creates a child particle that hosts some emitters described in the particleEffectFile.
Definition at line 249 of file particle.cpp.
|
inline |
Adds an emitter to the particle.
Definition at line 128 of file particle.h.
Particle * Particle::addTextRiseFadeOutEffect | ( | const std::string & | text, |
int | x, | ||
int | y, | ||
const gcn::Color * | color, | ||
gcn::Font * | font, | ||
bool | outline = false |
||
) |
Creates a standalone text particle.
Definition at line 383 of file particle.cpp.
Particle * Particle::addTextSplashEffect | ( | const std::string & | text, |
int | x, | ||
int | y, | ||
const gcn::Color * | color, | ||
gcn::Font * | font, | ||
bool | outline = false |
||
) |
Creates a standalone text particle.
Definition at line 364 of file particle.cpp.
void Particle::adjustEmitterSize | ( | int | w, |
int | h | ||
) |
Changes the size of the emitters so that the effect fills a rectangle of this size.
Definition at line 401 of file particle.cpp.
void Particle::clear | ( | ) |
Deletes all child particles and emitters.
Definition at line 423 of file particle.cpp.
Particle * Particle::createChild | ( | ) |
Creates a blank particle as a child of the current particle Useful for creating target particles.
Definition at line 242 of file particle.cpp.
|
inline |
After calling this function the particle will only request deletion when kill() is called.
Definition at line 247 of file particle.h.
|
inline |
Gets the flag if the particle is supposed to be moved by its parent.
Definition at line 201 of file particle.h.
|
overridevirtual |
Draws the particle image.
Implements Actor.
Reimplemented in TextParticle.
Definition at line 80 of file particle.cpp.
|
inlineoverridevirtual |
Do not draw particles when behind other objects.
Reimplemented from Actor.
Reimplemented in TextParticle.
Definition at line 95 of file particle.h.
|
inlineoverridevirtual |
Returns the current alpha value used to draw the actor.
Implements Actor.
Definition at line 250 of file particle.h.
|
protected |
Calculates the current alpha transparency taking current fade status into account.
Definition at line 410 of file particle.cpp.
|
inline |
Definition at line 228 of file particle.h.
|
inline |
Determines whether the particle and its children are all dead.
Definition at line 234 of file particle.h.
|
inline |
Manually marks the particle for deletion.
Definition at line 240 of file particle.h.
void Particle::moveBy | ( | const Vector & | change | ) |
Changes the particle position relative.
Definition at line 228 of file particle.cpp.
|
inline |
Sets the position in 3 dimensional space in pixels relative to map.
Definition at line 134 of file particle.h.
void Particle::moveTo | ( | float | x, |
float | y | ||
) |
Sets the position in 2 dimensional space in pixels relative to map.
Definition at line 237 of file particle.cpp.
|
inline |
Definition at line 225 of file particle.h.
|
inlineoverridevirtual |
Sets the alpha value used to draw the actor.
Implements Actor.
Definition at line 253 of file particle.h.
|
inline |
Sets the ammount of velocity particles retain after hitting the ground.
Definition at line 189 of file particle.h.
|
inlinevirtual |
Definition at line 255 of file particle.h.
|
inline |
Makes the particle move toward another particle with a given acceleration and momentum.
Definition at line 208 of file particle.h.
|
inline |
Sets the distance in pixel the particle can come near the target particle before it is destroyed.
Does only make sense after a target particle has been set using setDestination.
Definition at line 216 of file particle.h.
|
inline |
Sets the remaining particle lifetime where the particle starts to fade out.
Definition at line 164 of file particle.h.
|
inline |
Sets the age of the pixel in game ticks where the particle has faded in completely.
Definition at line 157 of file particle.h.
|
inline |
Sets the flag if the particle is supposed to be moved by its parent.
Definition at line 195 of file particle.h.
|
inline |
Sets the downward acceleration.
Definition at line 176 of file particle.h.
|
inline |
Sets the time in game ticks until the particle is destroyed.
Definition at line 150 of file particle.h.
|
inline |
Sets the ammount of random vector changes.
Definition at line 182 of file particle.h.
|
static |
Gives a particle the properties of an engine root particle and loads the particle-related config settings.
Definition at line 71 of file particle.cpp.
|
inline |
Sets the current velocity in 3 dimensional space.
Definition at line 170 of file particle.h.
|
virtual |
Updates particle position, returns false when the particle should be deleted.
Reimplemented in AnimationParticle, and RotationalParticle.
Definition at line 85 of file particle.cpp.
|
static |
Duration of pause between two emitter updates in ticks.
Definition at line 58 of file particle.h.
|
static |
true when non-crucial particle effects are disabled
Definition at line 59 of file particle.h.
|
static |
Mode of squareroot calculation.
Definition at line 55 of file particle.h.
|
private |
Acceleration towards the target particle in pixels per game-tick.
Definition at line 289 of file particle.h.
|
private |
Is the particle supposed to be drawn and updated?
Definition at line 272 of file particle.h.
|
private |
Can the effect size be adjusted by the object props in the map file?
Definition at line 277 of file particle.h.
|
protected |
Opacity of the graphical representation of the particle.
Definition at line 260 of file particle.h.
|
private |
May the particle request its deletion by the parent particle?
Definition at line 274 of file particle.h.
|
static |
Maximum number of particles.
Definition at line 57 of file particle.h.
|
private |
How much the particle bounces off when hitting the ground.
Definition at line 284 of file particle.h.
|
private |
List of child emitters.
Definition at line 275 of file particle.h.
|
private |
List of particles controlled by this particle.
Definition at line 276 of file particle.h.
|
private |
Particle effect file to be spawned when the particle dies.
Definition at line 278 of file particle.h.
|
private |
Bitfield of death conditions which trigger spawning of the death particle.
Definition at line 279 of file particle.h.
|
protected |
Age in game ticks where fading in is finished.
Definition at line 268 of file particle.h.
|
protected |
Lifetime in game ticks left where fading out begins.
Definition at line 267 of file particle.h.
|
private |
is this particle moved when its parent particle moves?
Definition at line 285 of file particle.h.
|
private |
Downward acceleration in pixels per game-tick.
Definition at line 282 of file particle.h.
|
private |
Distance in pixels from the target particle that causes the destruction of the particle.
Definition at line 290 of file particle.h.
|
protected |
Lifetime left in game ticks.
Definition at line 265 of file particle.h.
|
protected |
Age of the particle in game ticks.
Definition at line 266 of file particle.h.
|
private |
How much speed the particle retains after each game tick.
Definition at line 291 of file particle.h.
|
private |
Ammount of random vector change.
Definition at line 283 of file particle.h.
|
private |
The particle that attracts this particle.
Definition at line 288 of file particle.h.
|
protected |
Speed in pixels per game-tick.
Definition at line 269 of file particle.h.
|
static |
Maximum Z position of particles.
Definition at line 54 of file particle.h.
|
static |
Current number of particles.
Definition at line 56 of file particle.h.