[cocos2d

[cocos2d

相信使用cocos2d官方论坛提供的截屏方法,或者其他使用openGL方式截屏的同志们,会发现在ios6的真机下,这种截屏方式无效。 下面给出两种解决方案,已经在iphone4s 和 iphone5 真机测试过,并支持iphone5的宽屏 

 方案1:修改GLView preserveBackbuffer参数 为YES 将代码: 

EAGLView *glView = [EAGLView viewWithFrame:[window bounds]   pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8   depthFormat:0 // GL_DEPTH_COMPONENT16_OES ]; 

 修改成 

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

 方案2:使用CCDirector方式截屏 代码如下 

 

+(UIImage*) makeaShot

{

    [CCDirector sharedDirector].nextDeltaTimeZero = YES;

    

    CGSize winSize = [CCDirector sharedDirector].winSize;

    

    CCLayerColor* whitePage = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 0) width:winSize.width height:winSize.height];

    whitePage.position = ccp(winSize.width/2, winSize.height/2);

    

    CCRenderTexture* rtx = [CCRenderTexture renderTextureWithWidth:winSize.width height:winSize.height];

    [rtx begin];

    [whitePage visit];

    [[[CCDirector sharedDirector] runningScene] visit];

    [rtx end];

    

    return [rtx getUIImageFromBuffer];

}

发布者:admin,转转请注明出处:http://www.yc00.com/news/1689437987a248223.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信