Cocos2dx 截屏

时间:2022-01-18 23:26:01
void SaveScreenshot()
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCRenderTexture* texture = CCRenderTexture::create((int)size.width, (int)size.height);
texture->setPosition(ccp(size.width/2, size.height/2));
texture->begin();
CCDirector::sharedDirector()->getRunningScene()->visit();
texture->end();
texture->saveToFile("screenshot.png", kCCImageFormatPNG);
}