Cocos2d iphone 如何在ApplicationIdentinterBackground上检测/查找完全透明的屏幕截图?
我正在使用这段代码在ApplicationIdentinterBackground上保存一个屏幕截图,当场景在后台加载时,该截图将作为加载屏幕显示Cocos2d iphone 如何在ApplicationIdentinterBackground上检测/查找完全透明的屏幕截图?,cocos2d-iphone,screenshot,multitasking,Cocos2d Iphone,Screenshot,Multitasking,我正在使用这段代码在ApplicationIdentinterBackground上保存一个屏幕截图,当场景在后台加载时,该截图将作为加载屏幕显示 @implementation CCDirector(ScreenShot) +(void)saveScreenshotWithFilename: (NSString*) filename { [CCDirector sharedDirector].nextDeltaTimeZero = YES; CGSize winSize =
@implementation CCDirector(ScreenShot)
+(void)saveScreenshotWithFilename: (NSString*) filename {
[CCDirector sharedDirector].nextDeltaTimeZero = YES;
CGSize winSize = CCDirector.sharedDirector.winSize;
CCRenderTexture * renderTexture = [CCRenderTexture renderTextureWithWidth:winSize.width
height:winSize.height
pixelFormat:kCCTexture2DPixelFormat_RGBA8888
depthStencilFormat:GL_DEPTH_COMPONENT16];
[renderTexture beginWithClear:0 g:0 b:0 a:0 depth:1.0f];
[CCDirector.sharedDirector.runningScene visit];
[renderTexture end];
UIImage *image = [renderTexture getUIImage];
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingFormat:@"/%@", filename];
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES];
}
@end
它工作正常,但如果用户点击应用图标运行应用程序,然后按home按钮,然后快速连续地再次点击应用程序图标,则生成的屏幕截图是一个透明的PNG文件,尺寸正确,但完全透明
如何检查此特殊情况,以显示其他图像作为加载屏幕
…或者更好的是,透明屏幕截图有解决办法吗?在WilenterForeground中运行计时器,仅在应用程序已在前台运行了x个小时后才拍摄屏幕截图seconds@LearnCocos2D这比我目前的方法要好,即将默认的加载屏幕放在CCSprite中,并在
[CCDirector.sharedDirector.runningScene-visit]
拍摄屏幕截图时