質問

I am trying to set my particle's color to be black like follows. My background color is gray, other colors like red shows up but the black doesn't. Isn't black RGB (0,0,0)? Thanks in advance.

startColor.r = 0.0f;
startColor.g = 0.0f;
startColor.b = 0.0f;
startColor.a = 1.0f;

startColorVar.r = 0.0f;
startColorVar.g = 0.0f;
startColorVar.b = 0.0f;
startColorVar.a = 0.0f;

endColor.r = 0.0f;
endColor.g = 0.0f;
endColor.b = 0.0f;
endColor.a = 1.0f;

endColorVar.r = 0.0f;
endColorVar.g = 0.0f;
endColorVar.b = 0.0f;
endColorVar.a = 0.0f;

self.blendFunc = (ccBlendFunc){GL_SRC_ALPHA, GL_DST_ALPHA}; 
役に立ちましたか?

解決

Isn't black RGB (0,0,0)?

Precisely. cocos2d uses additive blending equation (glBlendEquation(GL_FUNC_ADD)), so with source color of RGB(0, 0, 0) and your blend function resulting color is equal to destination color (background).

cocos2d doesn't expose blending equation. You can use {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA} as blend function or subclass CCParticleSystemand specify different blending equation in its draw method.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top