我感兴趣的开发粒子引擎,我可以调用类似.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