Note that there are some explanatory texts on larger screens.

plurals
  1. POOptimising particle effects for slower phones
    text
    copied!<p>I'm making a libGDX game that uses particle effects for explosions. This runs quite well on new phones but on older phones (tested on the HTC Desire) when there are more than a few explosions on screen fps lags quite significantly. </p> <p>There are two options I'm currently considering: </p> <ol> <li><p>There are a lot of particles per effect so reducing that count may be an option but I would rather not for consistency and aesthetic reasons. </p></li> <li><p>Using an animation generated from running the particle effect and saving each frame. This would look nice and would be consistent. There may be issues with image size. I also can't see how this can be done with the libGDX particle implementation. </p></li> </ol> <p>Any ideas?</p> <p><strong>EDIT:</strong> Some snippets of the code: After loading the effect in the Assets class:</p> <pre><code>particleFire.load(Gdx.files.internal("explosion.p"),Gdx.files.internal("")); </code></pre> <p>I load the particle effect in the projectile object's constructor. I'm doing this object creation in the main rendering loop which I know is a candidate for optimization.</p> <pre><code> explosion = new ParticleEffect(Assets.particleFire); </code></pre> <p>In the rendering thread this method is called to draw the effects.</p> <pre><code> private void drawBlasts(float delta){ for(Missile projectile : world.missiles){ if (projectile.missileState == State.EXPLODING){ if(projectile.stateTime==0.0f) { projectile.explosion.start(); continue; } projectile.explosion.setPosition(projectile.position.x, projectile.position.y); projectile.explosion.draw(spriteBatcher, delta); } } } </code></pre> <p>A snippet of explosion.p</p> <pre><code>- Delay - active: false - Duration - lowMin: 1000.0 lowMax: 1000.0 - Count - min: 0 max: 100 - Emission - lowMin: 0.0 lowMax: 0.0 highMin: 250.0 highMax: 250.0 relative: false scalingCount: 1 scaling0: 1.0 timelineCount: 1 timeline0: 0.0 - Life - lowMin: 800.0 lowMax: 800.0 highMin: 1000.0 highMax: 1000.0 relative: false scalingCount: 3 scaling0: 1.0 scaling1: 1.0 scaling2: 1.0 timelineCount: 3 timeline0: 0.0 timeline1: 0.66 timeline2: 0.9931507 </code></pre> <p>EDIT 2: These effects are additive so there is a good bit of blending going on too.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload