我使用libgdx在我的Android设备上开火:
ParticleEffect effect;
ParticleEffectPool fireEffectPool;
Array<PooledEffect> effects = new Array<PooledEffect>();
@Override
public void create()
{
...
effect = new ParticleEffect();
effect.load(Gdx.files.internal("particles/fire01.p"), Gdx.files.internal("image"));
effect.setFlip(true, false);
fireEffectPool = new ParticleEffectPool(effect, 1000, 3000);
PooledEffect myEffect = fireEffectPool.obtain();
myEffect.setPosition(200, 400);
effects.add(myEffect);
...
}
我可以通过编程方式旋转,设置速度还是缩放效果?
答案 0 :(得分:5)
是。查看ParticleEmitterTest:https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/ParticleEmitterTest.java
你只需要获得一个ParticleEmitter:
emitter = effect.getEmitters().first();
emitter.getScale().setHigh(5, 20);
答案 1 :(得分:5)
通过使用此代码作为基础,我找到了粒子效果旋转问题的解决方案 http://badlogicgames.com/forum/viewtopic.php?f=11&t=7060#p32607
添加一个小变化以保持效果的幅度。希望能帮助到你。
public void rotateBy(float amountInDegrees) {
Array<ParticleEmitter> emitters = particleEffect.getEmitters();
for (int i = 0; i < emitters.size; i++) {
ScaledNumericValue val = emitters.get(i).getAngle();
float amplitude = (val.getHighMax() - val.getHighMin()) / 2f;
float h1 = amountInDegrees + amplitude;
float h2 = amountInDegrees - amplitude;
val.setHigh(h1, h2);
val.setLow(amountInDegrees);
}
}
}