Java 发动机粒子系统

Java 发动机粒子系统,java,android,andengine,Java,Android,Andengine,我想使用AndEngine的粒子系统来创建一个飞溅(如在飞溅的水中) 我已经查看了粒子系统的示例,但并不确定需要做什么才能使用粒子系统创建水的飞溅效果 有什么想法吗?我不知道任何水花模拟算法,所以我会照我的想法去做,但你必须进行修改,使其看起来真实 2D中的水花动画将从单个位置创建许多小水滴,然后以初始速度将每个水滴发送到不同的方向,然后每个水滴减慢并逐渐消失 试试这个: public ParticleSystem createParticleSystem(final TextureRegion

我想使用AndEngine的粒子系统来创建一个飞溅(如在飞溅的水中)

我已经查看了粒子系统的示例,但并不确定需要做什么才能使用粒子系统创建水的飞溅效果


有什么想法吗?

我不知道任何水花模拟算法,所以我会照我的想法去做,但你必须进行修改,使其看起来真实

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);

也许是个更好的选择?谢谢,我也会在那里发帖的。看起来我们有更多的用户在这里提供帮助。没错,这里有更多的流量。不确定双重张贴或甚至链接将是一种方式。我会在这里看到它是如何运行的,如果没有发生任何事情,我会把它迁移过来。对于我过去的大多数问题和引擎开发问题,我在这里得到了很好的回答。在gamedev,我一个也没有得到=/。我可以想象。我会让它在这里运行,如果你什么都没有得到,最终,标记它以引起版主的注意,并要求迁移它。祝你好运我刚开始学习英语,所以我还帮不上忙。谢谢。我会试试的!png应该仅仅是一滴水吗?这是一个很好的解决方案。刚刚注意到ParticleSystem的最大/最小速率是颠倒的。与AlphaModifier的参数相同。对于GLES2,初始化器类具有中缀粒子。我希望这有帮助,干杯。