Game Development Reference
In-Depth Information
2. Then, create a
PlayEffect
instance for each of
ParticleEmitters
and set
the effect accordingly with
emitAllParticles
set to
true
.
3. Create a new
Timer
instance called
explosionTimer
.
4. Add a new
TimerEvent
at time 0 where it triggers the
flash
,
spark
,
smoke
,
debris
, and
shockwave
effects, by calling
trigger()
on each of
the
PlayEffects
, as shown in the following code:
explosionTimer.addTimerEvent(0, new
Timer.TimerEvent() {
public Object[] call() {
flashEffect.trigger();
sparkEffect.trigger();
...
return null;
}
});
5. Then, add another
TimerEvent
at time
0.05f
, which triggers the
flame
and
roundSpark
effects.
6. The last
TimerEvent
should happen at time
5f
and should call
stop()
on all
of the effects.
7. Finally, we create a
ScriptAppState
instance to which we add
explo-
sionTimer
and then add it to
stateManager
using the following code:
ScriptAppStateappState = new ScriptAppState();
stateManager.attach(appState);
appState.addScriptObject(explosionTimer);
8. Now, we can trigger
explosionTimer
. It should perform the explosion in the
same way as
TestExplosion
does.