In my game I use
static final float FRUSTUM_WIDTH = 10;
static final float FRUSTUM_HEIGHT = 15;
So when I draw the particles they take the whole screen and are huge! So how do I scale them down to fit my needs?
//Pew Labs
ParticleEffect pe = new ParticleEffect();
pe.load(Gdx.files.internal("data/particle/particle.p"), Gdx.files.internal("data/particle"));
pe.setPosition(x, y);
float pScale = 0.2f;
float scaling = pe.getEmitters().get(0).getScale().getHighMax();
pe.getEmitters().get(0).getScale().setHigh(scaling * pScale);
scaling = pe.getEmitters().get(0).getScale().getLowMax();
pe.getEmitters().get(0).getScale().setLow(scaling * pScale);
scaling = pe.getEmitters().get(0).getVelocity().getHighMax();
pe.getEmitters().get(0).getVelocity().setHigh(scaling * pScale);
scaling = pe.getEmitters().get(0).getVelocity().getLowMax();
pe.getEmitters().get(0).getVelocity().setLow(scaling * pScale);
Either you use the particle editor (to be honest I don't think it's a good idea for sizing the particles, as you mentioned the particles won't get too small (for anything else I really recommend it)) or you just open the particle effect file. It should be generated by the editor or you can copy it from the examples. In this file search the fields below:
- Scale -
lowMin: 0.0
lowMax: 0.0
highMin: 0.6
highMax: 0.6
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
Adjust the highMin
and highMax
as needed.
Well, you can use the particle editor and adjust the size there:
http://www.badlogicgames.com/wordpress/?p=1255
I have used the same approach as Victor but what worked for me:
ParticleEffect effect = new ParticleEffect();
effect.load(Gdx.files.internal("particle/version1.p"), Gdx.files.internal("particle"));
effect.setPosition(x, .y);
float pScale = 0.02f;
float scaling;
Array<ParticleEmitter> emitters = effect.getEmitters();
for (ParticleEmitter e : emitters) {
scaling = e.getScale().getHighMax();
e.getScale().setHigh(scaling * pScale);
scaling = e.getScale().getLowMax();
e.getScale().setLow(scaling * pScale);
scaling = e.getVelocity().getHighMax();
e.getVelocity().setHigh(scaling * pScale);
scaling = e.getVelocity().getLowMax();
e.getVelocity().setLow(scaling * pScale);
scaling = e.getSpawnHeight().getHighMax();
e.getSpawnHeight().setHighMax(scaling * pScale);
scaling = e.getSpawnHeight().getLowMax();
e.getSpawnHeight().setLowMax(scaling * pScale);
scaling = e.getSpawnHeight().getHighMin();
e.getSpawnHeight().setHighMin(scaling * pScale);
scaling = e.getSpawnHeight().getLowMin();
e.getSpawnHeight().setLowMin(scaling * pScale);
scaling = e.getSpawnWidth().getHighMax();
e.getSpawnWidth().setHighMax(scaling * pScale);
scaling = e.getSpawnWidth().getLowMax();
e.getSpawnWidth().setLowMax(scaling * pScale);
scaling = e.getSpawnWidth().getHighMin();
e.getSpawnWidth().setHighMin(scaling * pScale);
scaling = e.getSpawnWidth().getLowMin();
e.getSpawnWidth().setLowMin(scaling * pScale);
scaling = e.getXOffsetValue().getLowMax();
e.getXOffsetValue().setLowMax(scaling * pScale);
scaling = e.getXOffsetValue().getLowMin();
e.getXOffsetValue().setLowMin(scaling * pScale);
scaling = e.getYOffsetValue().getLowMax();
e.getYOffsetValue().setLowMax(scaling * pScale);
scaling = e.getYOffsetValue().getLowMin();
e.getYOffsetValue().setLowMin(scaling * pScale);
}
effect.start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With