LibGDX: Particle scale

妖精的绣舞 提交于 2019-12-01 04:27:23

问题


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


回答1:


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.




回答2:


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);



回答3:


Well, you can use the particle editor and adjust the size there:

http://www.badlogicgames.com/wordpress/?p=1255




回答4:


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();


来源:https://stackoverflow.com/questions/9708490/libgdx-particle-scale

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!