[Solved] ControlSwitch shows mask sprite offset

[Solved] ControlSwitch shows mask sprite offset
0.0 0


cocos2d-x 3.0 RC0
When I place a ControlSwitch, I can see the mask sprite texture appearing, offset. It looks to be at twice the x/y position of the control. Have not tested this on a Andorid. I don’t see this in the Test CPP app, so this confuses me. The screen shot is from a brand new app made with the create project macro, and all I did was add in the ControlSwitch, with the images from the test app.

Screenshot 2014.03.31 17.23.01.png (37.7 KB)


can you upload the project?


Here you go. I had to remove the cocos2d folder to get it under 5MB


Hi @bing
Thanks for your feedback. I created a ticket here http://www.cocos2d-x.org/issues/4635 .


The issue was fixed at https://github.com/cocos2d/cocos2d-x/pull/6104
Please refer to the comments in my Pull Request. Thanks.


Another thing, remember to enable stencil buffer in AppController.mm

     window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
     CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
                                         pixelFormat: kEAGLColorFormatRGBA8
-                                        depthFormat: GL_DEPTH_COMPONENT16
+                                        depthFormat: GL_DEPTH24_STENCIL8_OES   // This line enables stencil buffer
                                  preserveBackbuffer: NO


Thanks, this worked for me.