Game Development Reference
In-Depth Information
Creating a timer trigger
In the
Creating a trigger system
recipe, we laid the foundation for a
Trigger
system as
well as created some basic implementations. A timer can be very useful when creating
complex scripts that rely on timing or sequenced events. Not only does it do the obvious
(trigger the blast of the door and then the soldiers running through) but it can also work as a
relay trigger in case many things should be triggered at the same time. In this recipe, we'll
create this
Timer
object as well as an actual implementation of it where it triggers an ex-
plosion with several components. To save some time, we'll use the
TestExplosion
test
from jMonkeyEngine to get
ParticleEmitters
set up and the timing for free. We'll
also create a new
ScriptObject
called
PlayEffect
, which controls the particle emit-
ters.