您的位置:首页 > 移动开发 > Cocos引擎

cocos2dx 截取屏幕保存至手机相册中

2017-11-17 15:21 1401 查看
isAppInstalled
auto pic = utils::captureNode(Director::getInstance()->getRunningScene());
time_t customTime = time(NULL);

std::string filePath;
#if CC_PLATFORM_ANDROID==CC_TARGET_PLATFORM
filePath = "/sdcard/DCIM/Camera/" + StringUtils::toString(customTime) + ".jpg";
pic->saveToFile(filePath);
#else
filePath = FileUtils::getInstance()->getWritablePath() + StringUtils::toString(customTime) + ".jpg";
pic->saveToFile(filePath);
#endif
Operator::requestChannel("sysmodule", "notifyScreenShot", filePath);

/*	GamePromptLayer* prompt = GamePromptLayer::create();
prompt->showPrompt(GBKToUtf8("截图成功"));*/
if (_BisScrenncallBack)
{
_BisScrenncallBack();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: