I using tip from this ask stackoverflow.com/questions/12413460 It's work. My problem is the image not refresh while application not restart or not rebuilding. I use method for create screenshot. I what have same functional: use touch scree, and screenshot will save into documents directory. User touch second, second screenshot save. And so. But in my app every time only first touch screenshot created, as it cached or buffer ed.
-(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];
}
I call it when user touch screen (for example)
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CCNode *n = [[[CCDirector sharedDirector] runningScene].children objectAtIndex:0];
UIImage *img = [self screenshotWithStartNode:n];//this image always same by one, same when user touch screen first time
CCSprite *spriteTemp = [CCSprite spriteWithCGImage:img.CGImage key:@"image"];
[self addChild:spriteTemp];
}
On the screen items have different position in time. First touch on the screen get right image.But all other touch create screenshots as first image and dose not change.
I think maybe it's buffer CCRenderTexture? or image cache? What i will do?
i try [img release] and try CGImageRelease(img.CGImage) after touch, but it crash app.