Time for action – sparks

When swords clash so hard that sparks fly, then you know there are heroes at work. Let's create some sparks and make them dash in random directions!

  1. Make a copy of Main.java and name the class Particle2Sparks.java. Remember to also refactor the first line of the main() method to Particle2Sparks app = new Particle2Sparks();.
  2. Copy the included file assets/Effects/spark.png into your project's assets/Effect directory. It includes a sprite animation of sparks.
  3. In the simpleInitApp() method, create a spark emitter and attach it to the scene:
    public void simpleInitApp() {
      ParticleEmitter sparksEmitter = new ParticleEmitter("Spark emitter", Type.Triangle, 60);
      rootNode.attachChild(sparksEmitter);
  4. Create a material, load the spark ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.