5

在我的游戏中,我使用

static final float FRUSTUM_WIDTH = 10;
 static final float FRUSTUM_HEIGHT = 15;   

所以当我绘制粒子时,它们占据了整个屏幕并且非常大!那么如何缩小它们以满足我的需求呢?

//皮尤实验室

4

5 回答 5

25
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);
于 2012-06-18T07:32:38.200 回答
5

要么使用粒子编辑器(老实说,我认为调整粒子大小不是一个好主意,因为你提到粒子不会变得太小(对于其他任何我真的推荐它))或者你只是打开粒子效果文件。它应该由编辑器生成,或者您可以从示例中复制它。在此文件中搜索以下字段:

- 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

根据需要调整highMinhighMax

于 2012-03-14T22:00:30.267 回答
2

好吧,您可以使用粒子编辑器并在那里调整大小:

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

于 2012-03-14T19:07:16.803 回答
2

我使用了与 Victor 相同的方法,但对我有用的是:

    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();
于 2015-11-30T18:58:23.520 回答
0

就个人而言,为了根据用户的屏幕处理我的粒子大小,我使用ScalingViewport它允许您以固定大小工作,并且它会根据设备的屏幕大小自动缩放。我通常将ScalingViewportfor aScaling.fill放在它的构造函数中;这可以防止粒子拉伸并看起来很糟糕。

于 2020-03-07T20:14:10.540 回答