1 好友邀请挑战
利用chooseAsync[选择好友] 或者 createAsync[已知好友ID的情况下直接选择好友]
updateAsync 可以在之前打开的窗口更新发送信息
// This will post a custom update. If the game is played in a messenger// chat thread, this will post a message into the thread with the specified// image and text message. And when people launch the game from this// message, those game sessions will be able to access the specified blob// of data through FBInstant.getEntryPointData().FBInstant.updateAsync({ action: 'CUSTOM', cta: 'Play', image: base64Picture, text: { default: 'Edgar just played BASH for 9 points!', localizations: { en_US: 'Edgar just played BASH for 9 points!', pt_BR: 'Edgar jogou BASH por 9 pontos!', } } template: 'WORD_PLAYED', data: { myReplayData: '...' }, strategy: 'IMMEDIATE', notification: 'NO_PUSH',}).then(function() { console.log('Message was sent successfully');});
Base64Pic 可以用 http://imgbase64.duoshitong.com/ 在线转换
或者利用 Creator的摄像机功能 截屏,再进行图片字符转换
let node = new cc.Node();node.parent = cc.director.getScene();let camera = node.addComponent(cc.Camera);// 设置你想要的截图内容的 cullingMaskcamera.cullingMask = 0xffffffff;// 新建一个 RenderTexture,并且设置 camera 的 targetTexture 为新建的 RenderTexture,这样 camera 的内容将会渲染到新建的 RenderTexture 中。let texture = new cc.RenderTexture();let gl = cc.game._renderContext;// 如果截图内容中不包含 Mask 组件,可以不用传递第三个参数texture.initWithSize(cc.visibleRect.width, cc.visibleRect.height, gl.STENCIL_INDEX8);camera.targetTexture = texture;// 渲染一次摄像机,即更新一次内容到 RenderTexture 中camera.render();// 这样我们就能从 RenderTexture 中获取到数据了let data = texture.readPixels();// 接下来就可以对这些数据进行操作了let canvas = document.createElement('canvas');let ctx = canvas.getContext('2d');canvas.width = texture.width;canvas.height = texture.height;let rowBytes = width * 4;for (let row = 0; row < height; row++) { let srow = height - 1 - row; let imageData = ctx.createImageData(width, 1); let start = srow*width*4; for (let i = 0; i < rowBytes; i++) { imageData.data = data[start+i]; } ctx.putImageData(imageData, 0, row);}let dataURL = canvas.toDataURL("image/jpeg");let img = document.createElement("img");img.src = dataURL;
2 .关于排行榜