Cocos2D 2.0 screenshots on iOS 6

前端 未结 4 1015
灰色年华
灰色年华 2020-12-03 18:56

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

4条回答
  •  不知归路
    2020-12-03 19:21

    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];
    }
    

    You can call it like this

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

提交回复
热议问题