coco2d-x3.0beta2版本截屏问题

我在使用3.0版本截屏的时候写了如下代码:
Size size = Director::getInstance() -> getWinSize();
RenderTexture * screen = RenderTexture::create(size.width, size.height);
screen -> begin();
Scene *temp = Director::getInstance() -> getRunningScene();
temp -> visit();
screen -> end();
screen -> saveToFile(“coco2d-x-screenshot.png”,Image::Format::PNG);
在模拟器上成功截取了一张图片并保存。
但是在真机调试时发现截取的那张图片是一张全黑色的图片。
同样的代码我在2.1.4版本真机调试时不会出现。
是3.0做了什么修改导致的么?

Hi, thank you for your feed back. We used new renderer for 3.0 beta2. which means visit will only send render command to the renderer. the actual rendering will happen when render::render() function is called. which is in the director::DrawScene();
So, you can not get the renderToTexture Result immediately. but you can get the result in the next frame.
more info for the new renderer: https://docs.google.com/a/cocos2d-x.org/document/d/17zjC55vbP_PYTftTZEuvqXuMb9PbYNxRFu0EGTULPK8/edit

@dabingnn
v2.2.1 have the same issue, how can i do ?

Updated

  1. RenderTexture saveToFile has updated, it logic is similar with V2.x, the texture will be save to file in this frame, but it is not save at the moment when you call the function saveToFile(…).

@mrsimple Thank you, could you give us a detailed description please? Did you get a black image when you save a PNG file? Or despite whatever type of image file, you can only get a black one?