当前位置: 代码迷 >> 综合 >> cocos creator调用云开发
  详细解决方案

cocos creator调用云开发

热度:70   发布时间:2024-01-26 08:21:15.0

1、新建一个微信小游戏

修改project.config.json 中的  "miniprogramRoot": "wechatgame/",

2、创建cocos creator新项目

构建中设置地址中的发布路径:

/Users/developer/Desktop/rich/wechatGame    这里是小游戏项目的根目录,注意大小写区别;

3、在cocos creator中调用云函数,如:

onLoad: function () {
this.label.string = this.text;
if (CC_WECHATGAME) {
wx.cloud.callFunction({
name: 'test',
success: function(res) {
console.log(res) // 3
},
fail: console.error
})
}

},

4、构建,发布

5、现在在微信小游戏构建后的代码中,找到game.js

wx.cloud.init({env:'test-8fii9'})

remoteDownloader.init();

window.boot();

在window.boot();前初始化cloud,即可

  相关解决方案