bool WorldWindow::saveSpriteImg(const std::string& fileName)
{
bool flag = false;
Size wsize = Director::getInstance()->getWinSize();
CCRenderTexture *texture = CCRenderTexture::create(wsize.width,wsize.height,Texture2D::PixelFormat::RGBA8888,GL_DEPTH24_STENCIL8);
texture->setPosition(ccp(0,0));
texture->ignoreAnchorPointForPosition(true);
texture->setAnchorPoint(CCPointZero);
texture->beginWithClear(0.0f,0.0f,0.0f);
// -- start 需要渲染的节点/Users/topgame1602/Desktop/saveSpriteImg.js
Node *n = _uiMainNode->getNodeByName("UI");
n->visit();
// -- end
texture->end();
// 当前渲染的节点
texture->saveToFile("aa1.png",kCCImageFormatPNG,true,[=](RenderTexture* t,const std::string& s){
CCLog("%s",s.c_str());
});
return flag;
}