Created
May 15, 2012 04:45
-
-
Save fictorial/2699203 to your computer and use it in GitHub Desktop.
cocos2d-iphone screenshots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "cocos2d.h" | |
@interface CCScreenshot: NSObject | |
+ (NSString *)screenshotPathForFile:(NSString *)file; | |
+ (CCRenderTexture *)screenshotWithStartNode:(CCNode*)startNode filename:(NSString*)filename; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "CCScreenshot.h" | |
@implementation CCScreenshot | |
+ (NSString *)screenshotPathForFile:(NSString *)file { | |
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString* documentsDirectory = [paths objectAtIndex:0]; | |
NSString* screenshotPath = [documentsDirectory stringByAppendingPathComponent:file]; | |
return screenshotPath; | |
} | |
+ (CCRenderTexture *)screenshotWithStartNode:(CCNode*)startNode filename:(NSString*)filename { | |
[CCDirector sharedDirector].nextDeltaTimeZero = YES; | |
CGSize winSize = [CCDirector sharedDirector].winSize; | |
CCRenderTexture* rtx = [CCRenderTexture renderTextureWithWidth:winSize.width height:winSize.height]; | |
[rtx begin]; | |
[startNode visit]; | |
[rtx end]; | |
[rtx saveBuffer:[self screenshotPathForFile:filename] format:kCCImageFormatPNG]; | |
return rtx; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://ios.biomsoft.com/2011/12/13/how-to-use-ccrendertexture-for-motion-blur-screenshots-and-drawing-sketches/#more-908