0
votes

I have a game which was originally written using cocos2d v2.x in XCode (no other utilities used).

I have been porting this over to a Spritebuilder project, and hence to cocos2d V3.x. I have come up against some odd behaviour which I can't solve or find an answer to.

I have a game object (a power meter) which is made up of a number of white segments which are coloured when created, so that some are red, some are yellow and some are green. When the segment is active, its opacity is 255. When deactivated, its opacity is 100. This worked perfectly before, but now, when I change the opacity using [segment setOpacity:100] the sprite becomes white. In fact, setting the opacity to any value makes it white and solid.

Any ideas what is causing this behaviour? The sprites are being drawn onto a CCRenderTexture which is created using CCTexturePixelFormat_RGBA8888.

Using [segment setColorRGBA:[CCColor colorWithCcColor4b:ccc4(220,40,40,100)]] does show as intended, but as soon as I modify the opacity, it becomes solid white again.

1

1 Answers

2
votes

I'm leaving this is case anyone else has the same problem: in V3 of cocos, opacity is a value between 0 and 1, not 0 and 255 as it was previously.