Package tripleplay.particle.effect
Class Drag
java.lang.Object
tripleplay.particle.Effector
tripleplay.particle.effect.Drag
Applies friction (drag) to particles.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(int index, float[] data, int start, float now, float dt) Applies this effector to theindex
th particle in the supplied buffer.
-
Constructor Details
-
Drag
public Drag(float drag) Creates a drag effector with uniform x and y drag.- Parameters:
drag
- the fraction of the velocity to preserve on each frame (0 to 1).
-
Drag
public Drag(float dragX, float dragY) Creates a drag effector with the specified x and y drag.- Parameters:
dragX
- the fraction of the x velocity to preserve on each frame (0 to 1).dragY
- the fraction of the y velocity to preserve on each frame (0 to 1).
-
-
Method Details
-
apply
public void apply(int index, float[] data, int start, float now, float dt) Description copied from class:Effector
Applies this effector to theindex
th particle in the supplied buffer. The effector must use theParticleBuffer
offsets to extract fields fromdata
, for example:float x = data[start+ParticleBuffer.POS_X]
.- Specified by:
apply
in classEffector
- Parameters:
index
- the index of the particle, which can be used to index into other per-particle data arrays.data
- the particle field data.start
- the offset intodata
at which the particle's fields start.now
- the number of seconds elapsed since the emitter came into being. Can be used to compute a particle's age.dt
- the amount of time (in fractions of a second) that has elapsed since the last update.
-