Hi
I have the following code:
I want to be able to generate an explosion!! It nearly works. Meaning that i can see the small sphere(just a test) and i can see like the last frame of the particle animation.
But i don't see the animation af the explosion occuring, or the particles fading away after the explosion - strange.
Am i missing some kind of update call every frame from the basegame???
I realize that you just helped GustavoBorba with a similar problem. Reading his topic did'nt help.
Any suggestions???
private ParticlePoints pPoints;
private Node model;
public Bomb(int x, int y) {
this.model = new Node();
this.model.setLocalTranslation(x, y, 0);
this.model.attachChild(new TestSphere(0.15f, ColorRGBA.black));
explode();
}
public void explode() {
Renderer display = DisplaySystem.getDisplaySystem().getRenderer();
if (display != null) {
pPoints = ParticleFactory.buildPointParticles("particles", 300);
pPoints.setLocalTranslation(1, 1, 1);
pPoints.setPointSize(3);
pPoints.setAntialiased(true);
pPoints.setEmissionDirection(new Vector3f(0, 1, 0));
pPoints.setOriginOffset(new Vector3f(0, 0, 0));
pPoints.setInitialVelocity(.003f);
pPoints.setStartSize(2.5f);
pPoints.setEndSize(.5f);
pPoints.setMinimumLifeTime(200);
pPoints.setMaximumLifeTime(1000);
pPoints.setStartColor(new ColorRGBA(1, 0, 0, 1));
pPoints.setEndColor(new ColorRGBA(0, 1, 1, 0));
pPoints.setMaximumAngle(360f * FastMath.DEG_TO_RAD);
pPoints.getParticleController().setControlFlow(false);
pPoints.warmUp(120);
BlendState as1 = display.createBlendState();
as1.setBlendEnabled(true);
as1.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
as1.setDestinationFunction(BlendState.DestinationFunction.One);
as1.setEnabled(true);
this.model.setRenderState(as1);
ZBufferState zstate = display.createZBufferState();
zstate.setEnabled(false);
pPoints.setRenderState(zstate);
pPoints.setModelBound(new BoundingSphere());
pPoints.updateModelBound();
this.model.attachChild(pPoints);
this.model.updateRenderState();
}
}