我感興趣的開發粒子引擎,我可以調用類似.createCollisionEffect(pos x, pos y, float duration);
Andengine粒子碰撞的影響(安卓遊戲開發)
,發動機會造成顆粒的隨機定向骨刺指定的時間。我發現下面的代碼,但我想用3層不同的紋理,因此隨機選擇一個,但我不知道如何管理時間和3層不同的紋理:我發現下面的代碼:
public ParticleSystem createParticleSystem(final TextureRegion textureRegion) {
//X & Y for the particles to spawn at.
final float particlesXSpawn = 400;
final float particlesYSpawn = 300;
//Max & min rate are the maximum particles per second and the minimum particles per second.
final float maxRate = 10;
final float minRate = 5;
//This variable determines the maximum particles in the particle system.
final int maxParticles = 100;
//Particle emitter which will set all of the particles at a ertain point when they are initialized.
final PointParticleEmitter pointParticleEmtitter = new PointParticleEmitter(particlesXSpawn, particlesYSpawn);
//Creating the particle system.
final ParticleSystem particleSystem = new ParticleSystem(pointParticleEmtitter, maxRate, minRate, maxParticles, textureRegion);
//And now, lets create the initiallizers and modifiers.
//Velocity initiallizer - will pick a random velocity from -20 to 20 on the x & y axes. Play around with this value.
particleSystem.addParticleInitializer(new VelocityInitializer(-20, 20, -20, 20));
//Acceleration initializer - gives all the particles the earth gravity (so they accelerate down).
particleSystem.addParticleInitializer(new GravityInitializer());
//And now, adding an alpha modifier, so particles slowly fade out. This makes a particle go from alpha = 1 to alpha = 0 in 3 seconds, starting exactly when the particle is spawned.
particleSystem.addParticleModifier((IParticleModifier) new AlphaModifier(3, 1, 0));
//Lastly, expire modifier. Make particles die after 3 seconds - their alpha reached 0.
particleSystem.addParticleModifier(new ExpireModifier(3));
return particleSystem;
}
燦任何人提供一些指導?提前致謝!
只是爲了澄清:你不是在試圖製造與物體碰撞的粒子,對吧?你正在發生碰撞時發生的粒子效應。那是你正在嘗試做什麼? – 2012-02-08 19:34:55
是的,你明白了! – Aziz 2012-02-09 04:50:54