本文介绍了CCShaky3D 将背景变为黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使我的精灵具有震动效果.然而,当精灵确实抖动时,整个背景变成黑色.有人可以帮我解决这个问题吗?

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];

谁能帮帮我?

推荐答案

你是否开启了EAGLView的深度缓冲?大多数 3D 动作需要深度缓冲(GL_DEPTH_COMPONENT16_OESGL_DEPTH_COMPONENT24_OES)以避免视觉伪影.您可能还必须通过使用 kEAGLColorFormatRGBA8 而不是 kEAGLColorFormatRGB565 来使用具有 alpha 通道的 32 位帧缓冲区.

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 在应用委托类中初始化:

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];

这篇关于CCShaky3D 将背景变为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:03