在some cocos2d-iphone documentation中,我被告知要把这个
// IMPORTANT: Call this function at the very beginning, before running your 1st scene
// Create a depth buffer of 24 bits
// These means that openGL z-order will be taken into account
[[CCDirector sharedDirector] setDepthBufferFormat:kDepthBuffer16];
通过动作在我的游戏中允许一些3D效果。但是,由于某些原因,XCode无法识别setDepthBufferFormat
和kDepthBuffer16
。有什么想法吗?
答案 0 :(得分:6)
遗憾的是,cocos2d文档已部分过时。您提到的方法不再存在。相反,您必须修改初始化EAGLView的app委托方法applicationDidFinishLaunching中的行。有一个“viewWithFrame”变体,它接受了depthFormat的额外参数:
// Create an EAGLView with a RGB8 color buffer, and a depth buffer of 24-bits
EAGLView* glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kCCTexture2DPixelFormat_RGBA8888
depthFormat:GL_DEPTH_COMPONENT16_OES
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];