I used a method that worked for me. It does a screenshot, and then selects a frame of it. You can change it, so it takes a screenshot from the whole screen.
Here's the code.
-(UIImage*) takeScreenShot
{
[CCDirector sharedDirector].nextDeltaTimeZero = YES;
CGSize winSize = [CCDirector sharedDirector].winSize;
//aux layer to make screenshot
CCLayerColor* blankLayer = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 0) width:winSize.width height:winSize.height];
blankLayer.position = ccp(winSize.width/2, winSize.height/2);
CCRenderTexture* rtx = [CCRenderTexture renderTextureWithWidth:winSize.width height:winSize.height];
//this part is the same as yours
[rtx begin];
[blankLayer visit];
[[[CCDirector sharedDirector] runningScene] visit];
[rtx end];
//this part makes a rectangle from the screenshot with size.width and 200 height. Change it
UIImage *tempImage =[rtx getUIImage];
CGRect imageBoundary = CGRectMake(0, 0, winSize.width, 200);
UIGraphicsBeginImageContext(imageBoundary.size);
CGContextRef context = UIGraphicsGetCurrentContext();
// translated rectangle for drawing sub image
CGRect drawRect = CGRectMake(-imageBoundary.origin.x, -imageBoundary.origin.y, tempImage.size.width, tempImage.size.height);
// clip to the bounds of the image context
CGContextClipToRect(context, CGRectMake(0, 0, imageBoundary.size.width, imageBoundary.size.height));
// draw image
[tempImage drawInRect:drawRect];
UIImage* subImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return subImage;
//and there you have an UIImage
}
This code works well when making screenshots of a part of the screen. Maybe you can try deleting the code part where it makes a temp image with a CGRect. But I recommend you to change the values like this:
CGRect imageBoundary = CGRectMake(0, 0, winSize.width, winSize.height);
So it will make a full screenshot.