Java examples for Game:JME3
Particle Burst jme3
package Effects;/*from www . j av a 2 s . c o m*/ import template.*; import com.jme3.app.SimpleApplication; import com.jme3.effect.ParticleEmitter; import com.jme3.effect.ParticleMesh.Type; import com.jme3.effect.shapes.EmitterSphereShape; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.renderer.RenderManager; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; /** * test * * @author normenhansen */ public class Particle5Burst extends SimpleApplication { public static void main(String[] args) { Particle5Burst app = new Particle5Burst(); app.start(); } @Override public void simpleInitApp() { ParticleEmitter burstEmitter = new ParticleEmitter("Burst emitter", Type.Triangle, 5); rootNode.attachChild(burstEmitter); Material burstMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); burstMat.setTexture("Texture", assetManager.loadTexture("Effects/flash.png")); burstEmitter.setImagesX(2); burstEmitter.setImagesY(2); burstEmitter.setSelectRandomImage(true); burstEmitter.setMaterial(burstMat); burstEmitter.setStartColor(new ColorRGBA(1f, 0.8f, 0.36f, 1f)); burstEmitter.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f)); burstEmitter.setStartSize(.1f); burstEmitter.setEndSize(3.0f); burstEmitter.setGravity(0, 0, 0); burstEmitter.setLowLife(.2f); burstEmitter.setHighLife(.2f); burstEmitter.getParticleInfluencer().setInitialVelocity( new Vector3f(0, 5f, 0)); burstEmitter.getParticleInfluencer().setVelocityVariation(1f); burstEmitter.setShape(new EmitterSphereShape(Vector3f.ZERO, .5f)); } @Override public void simpleUpdate(float tpf) { /* Pause a freshly initialized emitter until you need it. emitter.setParticlesPerSec(0); Start playing a 20-particle effect. Typically triggered by a game action or event. emitter.setParticlesPerSec(20); Stop the effect and remove all flying particles. emitter.emitAllParticles(); emitter.killAllParticles(); */ } @Override public void simpleRender(RenderManager rm) { //TODO: add render code } }