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
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
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.
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);
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();
Personally, to handle my particle size depending on the user's screen, I use ScalingViewport
which allows you to work at a fixed size and it'll automatically scale depending on the device'd screen size. I usually put the ScalingViewport
for a Scaling.fill
in its constructor; that prevents the particle from stretching and looking bad.