iOS 6上的Cocos2D 2.0截图 [英] Cocos2D 2.0 screenshots on iOS 6

查看:112
本文介绍了iOS 6上的Cocos2D 2.0截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序拍摄场景的屏幕截图并将其保存到文件。我有这个工作,应用程序是在商店。今天,我已经下载iOS 6,我使用的方法不再工作了。我测试了我所知道的一切,使它工作,搜索并找到这一点:

I have an application that takes a screenshot of a scene and saves it to a file. I have this working and the application is on the store. Today, I have downloaded iOS 6 and the method I am using is not working anymore. I tested all I know to make it work, googled around and found this:

http://www.cocos2d-iphone.org/forum/topic/37809?replies=22#post-180983

用户似乎同意这是在iOS 5上工作,但我已经在iOS 6上测试了它,并且它正在生产黑屏截图。

Users seem to agree that this is working on iOS 5, but I have tested this on iOS 6 and it is producing black screenshots.

我不是Cocos2D的专家,所以我不能说这个家伙的代码是什么问题。作者在github上有一个示例项目,甚至他的项目在iOS 6上生成黑屏截图。

I am not a specialist in Cocos2D so, I cannot say exactly what is wrong with this guy's code. the author has a sample project on github and even his project is producing black screenshots on iOS 6.

任何线索?感谢。

感谢

推荐答案

我不知道GitHub版本,但这个代码将截图,我只是在iOS 6上测试它,它工作正常。

I am not sure what the GitHub version does but this code will take a screenshot and I just tested it on iOS 6 and it works fine.

+(UIImage*) screenshotWithStartNode:(CCNode*)startNode
{
    [CCDirector sharedDirector].nextDeltaTimeZero = YES;

    CGSize winSize = [CCDirector sharedDirector].winSize;
    CCRenderTexture* rtx = 
    [CCRenderTexture renderTextureWithWidth:winSize.width 
                                 height:winSize.height];
    [rtx begin];
    [startNode visit];
    [rtx end];

    return [rtx getUIImage];
}

您可以像这样调用

CCScene *scene = [[CCDirector sharedDirector] runningScene];
CCNode *n = [scene.children objectAtIndex:0];
UIImage *img = [AppController screenshotWithStartNode:n];

这篇关于iOS 6上的Cocos2D 2.0截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆