CCShaky3D turns the background black

时光怂恿深爱的人放手 提交于 2019-12-22 18:15:39

问题


I'm trying to make my sprite have a shake effect. However, while the sprite does shake, the entire background turns black. Can anybody help me with this?

Here's the code that I've written to add the sprite to my layer along with the action that I run right after.

CCSprite * picture = [CCSprite spriteWithFile:@"picture.png"];
picture.position = ccp(winsize.width/4,
                       picture.contentSize.height * 0.8);
[self addChild:picture];
CCShaky3D * shake = [CCShaky3D actionWithRange:4
                                        shakeZ:NO
                                          grid:ccg(12, 12)
                                      duration:0.5];
[picture runAction:shake];

Can anybody help me?


回答1:


Have you enabled depth buffering of the EAGLView? Most 3D actions require depth buffering (GL_DEPTH_COMPONENT16_OES or GL_DEPTH_COMPONENT24_OES) to avoid visual artifacts. You may also have to use a 32-Bit frame buffer with alpha channels by using the kEAGLColorFormatRGBA8 instead of kEAGLColorFormatRGB565.

EAGLView is initialized in the app delegate class:

EAGLView* glView = [EAGLView viewWithFrame:[window bounds]
                               pixelFormat:kEAGLColorFormatRGBA8
                               depthFormat:GL_DEPTH_COMPONENT24_OES
                        preserveBackbuffer:NO
                                sharegroup:nil
                             multiSampling:0
                           numberOfSamples:0];


来源:https://stackoverflow.com/questions/8191915/ccshaky3d-turns-the-background-black

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!