代码语言:javascript复制
utils::captureScreen(CC_CALLBACK_2(HelloWorld::afterCapture, this), "D:/MyCocosProj/FallDown/Resources/ScreenShot.png");
然后在回调函数
代码语言:javascript复制void HelloWorld::afterCapture(bool succeed, const std::string& outputFile)
{
if (succeed)
{
CCLOG("outputFile = %s", outputFile.c_str());
//显示截图
Sprite* sp = Sprite::create(outputFile);
sp->setPosition(ccp(100,100));
this->addChild(sp);
sp->setScale(0.25); //放缩
}
else
{
CCLOG("Capture screen failed.");
}
}