Package tripleplay.particle.effect
Class Gravity
java.lang.Object
tripleplay.particle.Effector
tripleplay.particle.effect.Gravity
Applies uniform gravity to particles.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(int index, float[] data, int start, float now, float dt) Applies this effector to theindexth particle in the supplied buffer.
-
Field Details
-
EARTH_G
public static final float EARTH_GEarth gravity.- See Also:
-
-
Constructor Details
-
Gravity
public Gravity()Creates a gravity effector with earth equivalent gravity. -
Gravity
public Gravity(float accel) Creates a gravity effector.- Parameters:
accel- the constant acceleration to apply to the y velocity of a particle. Positive accelerates the particle toward the bottom of the screen.
-
-
Method Details
-
apply
public void apply(int index, float[] data, int start, float now, float dt) Description copied from class:EffectorApplies this effector to theindexth particle in the supplied buffer. The effector must use theParticleBufferoffsets to extract fields fromdata, for example:float x = data[start+ParticleBuffer.POS_X].- Specified by:
applyin 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 intodataat 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.
-