Particles in StandardGame

Hi all! I have a question regarding ParticleGeneration in StandardGame. Since most samplecodes use "extends SimpleGame" I experienced some problems "converting" them to StandardGame using Particles in a "BasicGameState" class.

As for the I can use a function like spawnParticles() in the simpleInitGame() function to get a nice result:

public void spawnParticles(){
    pPoints = ParticleFactory.buildPointParticles("particles", 50);
    pPoints.setEmissionDirection(new Vector3f(0, 1, 0));
    pPoints.setOriginOffset(new Vector3f(0, 0, 0));

It does not work however in StandardGame using this method within a GameState class. If I put this code 1:1 into the update() method of my GameState (of course it's only "spawnParticles()" then) the FPS get very low and stuttering occurs. Also all Particles stay on the origin and don't get emitted at all. Therefore all I get is a colored Point which changes its color each frame.

Any hints on how to get this right? I didn't found a solution while searching the forums. :( :?

If you put the spawn into update you'd be regenerating your particle emitter every frame.

What shall I say… this hint brought me to the right solution XD. Since I'm still a beginner to this nice engine it sometimes needs a small hint to get things to work.

So the solution is following line in the update() function:


Cool, glad you got it working. :slight_smile: