Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 explosion 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 emitters.

How to do it...

To be able to control a ParticleEmitter object from our script system, we need a new class to handle the ParticleEmitter object:

  1. Start by creating a new class called PlayEffect...