Make WeChat game screenshot with cocos crae

Reference document: https://developers.weixin.qq.com/minigame/dev/document/render/canvas/Canvas.toTempFilePathSync.html


Core code:

var canvas = cc.game.canvas; var width = cc.winSize.width; var height = cc.winSize.height; canvas.toTempFilePath({ x : 0, y: 0, width: width, height: height, destWidth: width, destHeight: height , success (res) {//. The screenshot can be saved console.log(res) wx. shareAppMessage({ imageUrl: res.tempFilePath })} }) // let tempFilePath = canvas.toTempFilePathSync({ // x : 0, // y: 0, // width: width,  // height: height, // destWidth: width, // destHeight: height < span class="hljs-comment">// }) // wx.shareAppMessage({ // imageUrl: tempFilePath // })

Leave a Comment

Your email address will not be published.