Let's have a look at a classic fire effect. You can use it in combination with a Point Light, for campfires, torches, or for a wizard's fireball spell.
Make a copy of
Main.java
and name the classParticle6Fire.java
. Remember to also refactor the first line of themain()
method toParticle6Fire app = new Particle6Fire();
.Copy the included file
assets/Effects/flame.png
into your project'sassets/Effect
directory. It includes a sprite animation of flames.Initialize the emitter, give it a material based on
Particle.j3md
, and attach it to the scene:public void simpleInitApp() { ParticleEmitter fireEmitter = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); Material fireMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); rootNode.attachChild(fireEmitter);
Our fire sprite animation is made up of 2 x 2 random flames:
fireMat.setTexture("Texture", assetManager.loadTexture("Effects/flame.png")); fireEmitter.setMaterial(fireMat); fireEmitter...