質問
Andengineの粒子システムを使用して、水しぶきのようにスプラッシュを作成したいと思います。
私は粒子システムの例をチェックしましたが、粒子システムを使用して水のスプラッシュ感情を作成するために何をする必要があるかについては本当にわかりません。
何か案は?
解決
Water Splash Simulation Algorithmsはわかりませんので、私は思うことをしますが、それを現実に見せるために変更する必要があります。
2Dのウォータースプラッシュアニメーションは、単一の場所から多くの小さな水滴を作成し、それぞれを初期速度で異なる方向に送り、各水滴が減速してフェードアウトします。
これを試してみてください:
public ParticleSystem createParticleSystem(final TextureRegion waterDropTextureRegion) {
//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, waterDropTextureRegion);
//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(new AlphaModifier(1, 0, 0, 3));
//Lastly, expire modifier. Make particles die after 3 seconds - their alpha reached 0.
particleSystem.addParticleModifier(new ExpireModifier(3));
return particleSystem;
}
私はそれをテストしていませんが、それはうまくいくと思います。値で遊んで、現実的に見えるアニメーションを見つけてみてください。
この方法は、各粒子の準備が整ったテクスチャ領域である引数を受け取ります。あなたの場合、それは水滴になると思います。
この方法を呼び出して、取得します ParticleSystem
, 、シーンに添付するだけです。
final ParticleSystem particleSystem = createParticleSystem(...);
scene.attachChild(particleSystem);
所属していません StackOverflow