iOS 6 上的 Cocos2D 2.0 截图 [英] Cocos2D 2.0 screenshots on iOS 6
问题描述
我有一个应用程序可以截取场景的屏幕截图并将其保存到文件中.我有这个工作,应用程序在商店里.今天,我已经下载了 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?replys=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屋!