cocos creator调用云开发

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.init({env:'test-8fii9'})
            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,即可

发布了53 篇原创文章 · 获赞 2 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/frankxixu/article/details/104043523
今日推荐