如何获取截屏?

时间:2013-11-11 12:51:14

标签: ios cocos2d-iphone screenshot social

我正在经历一个小问题。我可以通过此代码拍摄我的游戏的屏幕截图

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

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

return [rtx getUIImage];
}

现在我需要获取拍摄的屏幕截图,然后在社交网站上分享它...我知道它可以通过iPhone sdk但是可以通过cocos2d吗?

如果是,那么如何?

1 个答案:

答案 0 :(得分:0)

在iOS7中,UIKit中有一个新的API,可让您快速截取屏幕截图。

UIView * screenshot = [myView snapshotViewAfterScreenUpdates:NO];

此屏幕截图现在存储在此屏幕截图变量中。