相關(guān)定義
// > afterCaptured :該方法將在捕捉指令后被執(zhí)行罐监。
// > bool : 捕捉屏幕截圖是否成功。
// > string : 截圖存儲的路徑侈百。
// > filename :截圖的名字咳促。
// > 可以只是一個文件名包雀。 像這樣ScreenShot.png迟几。
// > 也可以是一個絕對路徑诗良。像這樣/sdcard/ScreenShot.png台猴。
void captureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename)
實(shí)現(xiàn)代碼
//屏幕截圖
void HelloWorld::capture(Ref* sender)
{
CCLOG("ScreenShot");
utils::captureScreen(CC_CALLBACK_2(HelloWorld::afterCapture, this), "ScreenShot.png");
}
//截圖后執(zhí)行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.");
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者