I am trying to use particle emitter to loop over a sprite sheet. But the particle emitter is looping over the sprite sheet too fast. How can I slow it down?
This is the following test case,
import com.jme3.app.SimpleApplication;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
public class TestCase extends SimpleApplication {
public static void main(String[] args) {
TestCase app = new TestCase();
app.showSettings = false;
app.start();
}
public void simpleInitApp() {
ParticleEmitter particleEmitter;
particleEmitter = new ParticleEmitter("Particle Emitter", ParticleMesh.Type.Triangle, 36);
Material particleMaterial = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
particleMaterial.setTexture("Texture", assetManager.loadTexture("butterfly_fly_1.png"));
particleEmitter.setMaterial(particleMaterial);
particleEmitter.setImagesX(12);
particleEmitter.setImagesY(3);
particleEmitter.setGravity(Vector3f.ZERO);
particleEmitter.setStartSize(1f);
particleEmitter.setEndSize(1f);
particleEmitter.setLowLife(1);
particleEmitter.setHighLife(1);
rootNode.attachChild(particleEmitter);
}
}
Thanks, that improved the situation. But is it desirable behavior? Shouldn’t setParticlesPerSec be somehow tied with tpf?
Also, what could be the reason of the white flash on the at the end of the animation?
I am using the following modified sprite sheet. I added the last two sprite to complete the 12x3 sprite sheet, but the modification should not cause the white flash?
I think this an unusual use of the particleEmitter. Fire just burns - rotating through a few frames. I didn’t find a way to slow it down (other that what I said before. I’m glad it’s working.) You might write your own animator that uses fps.
I did a shader to animate over a spritesheet. The code in the linked post is updated I think. But I guess your particle emitter is doing much the same thing
The particle emitter doesn’t support any speed setting…
Though I usually make my own shader for animated materials like this
Here is what I used in one of my android games:
The interesting code occurs in the vert shader. The frag one is very basic, it’s just a texture fetch. If you want more fancy stuff like lighting you’ll have to add it there.
You can consider this BSD license and use it wherever you want.