cocos2d-x 部分:
//获取屏幕尺寸,初始化一个空的渲染纹理对象
auto renderTexture = RenderTexture::create(visibleSize.width, visibleSize.height, Texture2D::PixelFormat::RGBA8888);
//清空并开始获取
renderTexture->beginWithClear(0.0f, 0.0f, 0.0f, 0.0f);
//遍历场景节点对象,填充纹理到RenderTexture中
Director::getInstance()->getRunningScene()->visit();
//结束获取
renderTexture->end();
//保存文件
renderTexture->saveToFile(fileName, format);
auto fullPath = FileUtils::getInstance()->getWritablePath() + fileName;
auto scheduleCallback = &, fullPath, screenShotCallback](float dt){
screenShotCallback(fullPath.c_str());
};
auto _schedule = Director::getInstance()->getRunningScene()->getScheduler();
_schedule->schedule(scheduleCallback, this, 0.0f, 0, 0.0f, false, "screenshot");
```
android部分:
public static void share(final String subject, final String context,
final String fullPath) {
_appActiviy.runOnUiThread(new Runnable() {
@Override
public void run() {
File file = new File(fullPath);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
shareIntent.putExtra(Intent.EXTRA_TEXT, context);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
_appActiviy.startActivity(Intent.createChooser(shareIntent,
subject));
}
});
}
```
问题是,现在文字可以分享,但是图片分享不了,大神们知道怎么回事吗?