Reputation: 109
My problem is that the particle effect has to run several times at the beginning to start working properly on Android. During the first few times, it is showing just one particle, then at one moment it shows too much of them and then the next run is normal. The effect is not continuous, its length is about 500ms. This is how it looks like:
It behaves in this way only on Android, on Desktop everything is pretty normal. Here is code, which I am using:
ParticleEffect starsEffect = new ParticleEffect();
starsEffect.load(Gdx.files.internal("particles/stars/effect.p"), Gdx.files.internal("particles/stars"));
starsEffect.setPosition(x, y);
starsEffectActor = new ParticleEffectActor(starsEffect);
stage.addActor(starsEffectActor);
Implementation of my ParticleEffectActor class:
public class ParticleEffectActor extends Actor {
ParticleEffect particleEffect;
public ParticleEffectActor(ParticleEffect particleEffect) {
super();
this.particleEffect = particleEffect;
}
@Override
public void draw(Batch batch, float parentAlpha) {
particleEffect.draw(batch);
}
@Override
public void act(float delta) {
super.act(delta);
particleEffect.update(delta);
}
public void start() {
particleEffect.start();
}
}
Upvotes: 3
Views: 517
Reputation: 283
The same thing happened to me and I had no idea a why. So I debugged it and turns out you are only supposed to call ParticleEffect().update(float)
while your effect is running.
So you should only update the effect after ParticleEffect().start()
was called.
Upvotes: 3