creator2.0.2 native游戏截屏微信分享
Posted shwhr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了creator2.0.2 native游戏截屏微信分享相关的知识,希望对你有一定的参考价值。
cocos creator 2.0.2后 游戏内截屏,native微信SDK分享代码:
public static wxShareScreenShot(sType: number) {
let node = new cc.Node();
node.parent = cc.director.getScene();
node.width = cc.view.getVisibleSize().width;
node.x = cc.view.getVisibleSize().height;
node.y = cc.view.getVisibleSize().width;
node.height = cc.view.getVisibleSize().height;
let camera = node.addComponent(cc.Camera);
camera.cullingMask = 0xffffffff;
let texture = new cc.RenderTexture();
texture.initWithSize(node.width, node.height);
camera.targetTexture = texture;
camera.render(null);
let data = texture.readPixels();
let width = texture.width;
let height = texture.height;
data = this.filpYImage(data, width, height)
let fileName = "result_share.jpg";
let fullPath = jsb.fileUtils.getWritablePath() + fileName;
if (jsb.fileUtils.isFileExist(fullPath)) {
jsb.fileUtils.removeFile(fullPath);
}
let success = jsb.saveImageData(data, width, height, fullPath);
if (success) {
if(this.isandroid){
jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "shareScreenShot","(Ljava/lang/String;Ljava/lang/String;)V",fullPath,sType.toString())
}
if (this.isios){
jsb.reflection.callStaticMethod("VXManager", "shareScreenShot:" , sType.toString());
}
camera.destroy();
texture.destroy();
}
}
以上是关于creator2.0.2 native游戏截屏微信分享的主要内容,如果未能解决你的问题,请参考以下文章
微信小程序系列:一携带参数跳转半屏微信小程序 先 A->B 后 B ->A
(微信小程序系列:一)携带参数跳转半屏微信小程序 先 A->B 后 B ->A