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

2019-04-15 17:01发布

isAppInstalledauto 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(); }