相关定义
// > afterCaptured :该方法将在捕捉指令后被执行。
// > bool : 捕捉屏幕截图是否成功。
// > string : 截图存储的路径。
// > filename :截图的名字。
// > 可以只是一个文件名。 像这样ScreenShot.png。
// > 也可以是一个绝对路径。像这样/sdcard/ScreenShot.png。
void captureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename)
实现代码
//屏幕截图
void HelloWorld::capture(Ref* sender)
{
CCLOG("ScreenShot");
utils::captureScreen(CC_CALLBACK_2(HelloWorld::afterCapture, this), "ScreenShot.png");
}
//截图后执行afterCapture
void HelloWorld::afterCapture(bool succeed, const std::string& outputFile)
{
if (succeed)
{
CCLOG("Capture screen succeed %s", outputFile.c_str());
//Sprite* sp = Sprite::create(outputFile);//截图使用
}
else
{
CCLOG("Capture screen failed.");
}
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。