BUGs in CCControlSwitch

BUGs in CCControlSwitch
0.0 0


i think there’s 2 bugs in CCControlSwitch, and the bugs was found on my android device(htc desire s)

1.this bug can be found in the TestCpp project(CCControlSwitchTest). if you press the HOME key, you will go to desktop of your phone, and the TestCpp will be switched to the background. After that if you switch that TestCpp app to the foreground from background, this bug will be reproduced. All of the CCSprites you loaded will become WHITE BLOCKs (there textures were lost?). only the CCControlSwitch has this bug, other controls work well.

  1. you see, the CCControlSwitch::create function needs CCSprite params. if i pass CCSprites which created WITH FILE to CCControlSwitch::create, the CCControlSwitch will be loaded ok. But if i pass CCSprites which created WITH FRAME NAME to CCControlSwitch::create, the CCControlSwitch will be loaded badly. if a CCSprite was created with frame name, the CCSprite would have a big texture contained other images. when the CCSprite::getTexture was called by CCControlSwitch’s init functions, the CCControlSwitch wouldn’t get the right texture.

Problem: black and white texture after sleep!!

I had the second problem myself. I fixed it by rendering the mask to a RenderTexture and using the RenderTexture instead of the mask sprite’s texture.

On top of initWithMaskSprite put the following code.

RenderTexture* rt = RenderTexture::create(maskSprite->getContentSize().width,maskSprite->getContentSize().height);
rt->clear(0, 0, 0, 0);

and replace maskSprite~~>getTexture with rt~~>getSprite()->getTexture()

good luck.


This bug still exists in v2.2.
Had to use png files instead of spritesheet.