pslib
Class TimedEmission

java.lang.Object
  extended by pslib.TimedEmission
All Implemented Interfaces:
PSBehaviour, PSConstants, PSEmission

public class TimedEmission
extends java.lang.Object
implements PSEmission, PSConstants

TimedEmission Class

The TimedEmission class implements the PSEmission interface allowing the automated emission of random particles derived from the object variables from any emitters to which it is assigned.

Unlike the TemplateEmission class, the particle emission interval and particle amount are user-specified and invariant.

See Also:
TemplateEmission

Field Summary
 
Fields inherited from interface pslib.PSConstants
CAM2D_LOOK, CAM2D_RIGHT, CAM2D_UP, CORNER, INVERSE, INVERSE_TRIANGULAR, LEADING, LINEAR, MIDPOINT, NONE, STATIC, TRAILING, TRIANGULAR
 
Constructor Summary
TimedEmission(DynamicParticle t, int i, int p)
          Create a new object instance with the specified variables
TimedEmission(WeightedList<DynamicParticle> t, int i, int p)
          Create a new object instance with the specified variables
 
Method Summary
 void addListener(ParticleListener p)
          Attach a particle listener
 void clearListeners()
          Clear all attached particle listeners
 boolean removeListener(ParticleListener p)
          Remove a particle listener
 void setActive(boolean a)
          Set the active state of the behaviour
 void setAlpha(float a, int v)
          Set the emitted particle alpha value and variance
 void setDecay(int d, int v)
          Set the emitted particle decay value and variance
 void setEmissionInterval(int i)
          Set the particle emission interval
 void setEmittedParticles(int p)
          Set the amount of particles emitted on each particle emission event
 void setPalette(WeightedList<PSColour> p)
          Set the particle colour palette
 void setSize(float s, int v)
          Set the emitted particle size value and variance
 void setTemplate(WeightedList<DynamicParticle> t)
          Set the particle template
 void update(DynamicParticle p)
          Update the specified particle (unused)
 void update(GenericEmitter e)
          Update the specified emitter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimedEmission

public TimedEmission(DynamicParticle t,
                     int i,
                     int p)
Create a new object instance with the specified variables

Default decay, size and alpha values are taken from the specified particle with 0% variance.

Parameters:
t - particle template
i - emission interval
p - particle amount

TimedEmission

public TimedEmission(WeightedList<DynamicParticle> t,
                     int i,
                     int p)
Create a new object instance with the specified variables

Default decay, size and alpha values are taken from a particle selected at random from the specified list with 0% variance.

Parameters:
t - particle template list
i - emission interval
p - particle amount
Method Detail

setTemplate

public final void setTemplate(WeightedList<DynamicParticle> t)
Set the particle template

The particle template specifies the list of particles from which emitted particles may be derived. If no palette is specified emitted particles will inherit their colour from the template.

Parameters:
t - particle template

setPalette

public final void setPalette(WeightedList<PSColour> p)
Set the particle colour palette

The particle colour palette specifies the list of colours from which emitted particles may select. If no palette is specified emitted particles will inherit their colour from the particle template.

Parameters:
p - colour palette

setActive

public final void setActive(boolean a)
Set the active state of the behaviour

A value of true will result in particle emission on the update routine of any emitters to which this behaviour is attached.

Default: true

Specified by:
setActive in interface PSEmission
Parameters:
a -

setEmissionInterval

public final void setEmissionInterval(int i)
Set the particle emission interval

The particle emission interval specifies how many calls are required to the GenericEmitter.update() between emission events. Typically emitter updates will occur on a per-frame basis, so in many cases this value may be viewed as a frame interval.

Parameters:
i - interval

setEmittedParticles

public final void setEmittedParticles(int p)
Set the amount of particles emitted on each particle emission event

Parameters:
p - particles

setDecay

public final void setDecay(int d,
                           int v)
Set the emitted particle decay value and variance

Parameters:
d - decay time (ms)
v - variance (+/- %)

setSize

public final void setSize(float s,
                          int v)
Set the emitted particle size value and variance

Parameters:
s - size
v - variance (+/- %)

setAlpha

public final void setAlpha(float a,
                           int v)
Set the emitted particle alpha value and variance

Parameters:
a - alpha
v - variance (+/- %)

update

public void update(GenericEmitter e)
Update the specified emitter

The update routine attaches random particles derived from the object variables to the specified emitter. References to created particles are sent to any attached listeners.

Specified by:
update in interface PSEmission
Parameters:
e - emitter

update

public void update(DynamicParticle p)
Update the specified particle (unused)

Specified by:
update in interface PSBehaviour
Parameters:
p - particle

addListener

public final void addListener(ParticleListener p)
Attach a particle listener

Attached listeners will receive a reference to created particles upon emission. If this object is assigned as behaviour to multiple emitters, attached listeners will receive particles from each.

Parameters:
p - particle listener

removeListener

public final boolean removeListener(ParticleListener p)
Remove a particle listener

Parameters:
p - particle listener
Returns:
false if the listener does not exist

clearListeners

public final void clearListeners()
Clear all attached particle listeners