Can the opacity of a CCSprite in a CCSpriteBatchNode be modified?
The following doesn’t seem to work:
((CCSprite *)[batchNode getChildByTag:myTag]).opacity = 0.5;
The sprite just disappears instead of showing up with modified opacity.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is why it’s a good idea to look at the types.
opacityproperty ofCCSpriteis GLubyte. Looking at GLubyte’s typedef, we see that it’s actually unsigned char, which means that it takes integer values from 0 to 255. Withsprite.opacity = 0.5you implicitly convert floating point value to unsigned char, fractional part of 0.5 is truncated, and sprite.opacity becomes 0.