com.threerings.opengl.util
Class Phaser

java.lang.Object
  extended by com.threerings.opengl.util.Phaser
All Implemented Interfaces:
Tickable

public abstract class Phaser
extends Object
implements Tickable

Provides a convenient way to effect updates that proceed through a set of discrete phases (for example: fade in, linger, fade out). Updates are always generated for phase end boundaries. For example, if there are two phases (0.5, 0.5) and 10.0 seconds elapse, one update is generated for the end of the first phase and one is generated for the end of the second phase.


Field Summary
protected  float _accum
          The time accumulated towards the next phase.
protected  float _cpct
          The complement of the percentage completed (1f - _pct).
protected  float[] _durations
          The durations of each phase.
protected  Method[] _methods
          The methods for each phase.
protected  float _pct
          The percentage of the current phase completed, from zero to one.
protected  int _phase
          The index of the current phase.
 
Constructor Summary
Phaser(Object... params)
          Creates a new phaser.
 
Method Summary
protected  void completed()
          Called when the last phase is completed.
 void tick(float elapsed)
          Updates the state of this object based on the elapsed time in seconds.
protected  void update(int phase, float pct)
          Performs an update for the indexed phase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_methods

protected Method[] _methods
The methods for each phase.


_durations

protected float[] _durations
The durations of each phase.


_phase

protected int _phase
The index of the current phase.


_accum

protected float _accum
The time accumulated towards the next phase.


_pct

protected float _pct
The percentage of the current phase completed, from zero to one.


_cpct

protected float _cpct
The complement of the percentage completed (1f - _pct).

Constructor Detail

Phaser

public Phaser(Object... params)
Creates a new phaser.

Parameters:
params - the names of the update methods to call for each phase and their corresponding phase durations (example: "fadeIn", 1f, null, 2f, "fadeOut", 1f). Update methods should be member methods with zero arguments.
Method Detail

tick

public void tick(float elapsed)
Description copied from interface: Tickable
Updates the state of this object based on the elapsed time in seconds.

Specified by:
tick in interface Tickable

update

protected void update(int phase,
                      float pct)
Performs an update for the indexed phase.

Parameters:
pct - the percentage of the phase completed, from zero to one.

completed

protected void completed()
Called when the last phase is completed.