我用LiquidFun来模拟水,这是一个基于box2d的物理引擎,它使用粒子。我的问题是当用特定的颜色渲染粒子时。
在粒子定义上设置粒子颜色的目的是什么?当您还必须设置要在ParticleDebugRenderer上呈现粒子的颜色时。
public void createWater(float x, float y){
ParticleDef def = new ParticleDef();
def.color.set(Color.Red); //set particle color
def.flags.add(ParticleDef.ParticleType.b2_tensileParticle);
def.flags.add(ParticleDef.ParticleType.b2_colorMixingParticle);
def.position.set(x, y);
int index = system.createParticle(def);
}ParticleDebugRenderer:
pdr = new ParticleDebugRenderer(Color.BLUE, maxParticles); //set as BLUE如果我将粒子设置为红色,它仍将以蓝色呈现,因为ParticleDebugRenderer被设置为蓝色。
发布于 2016-08-31 15:54:56
看看源代码,我们可以找到2个渲染器。
ParticleDebugRenderer.java和ColorParticleRenderer.java
它们的不同之处在于,ColorParticleRenderer从ParticleSystem获得颜色,ParticleDebugRenderer从构造器获取颜色。
主要的使用区别是我们每次都使用ColorParticleRenderer,而不是调试。当我们想要调试一个粒子时,可以使用ParticleDebugRenderer。我们使用它,因为我们不想在ParticleSystem的定义中更改颜色,因为
您的困惑来自于您在没有调试时使用的是ParticleDebugRenderer,因此您两次分配相同的颜色。
https://stackoverflow.com/questions/39251652
复制相似问题