美文网首页
cocos creater使用 async , await

cocos creater使用 async , await

作者: 凡凡的小web | 来源:发表于2019-08-09 10:41 被阅读0次

下载asyc.min.js
regenerator-runtime(或者polyfll.js)
https://www.npmjs.com/package/regenerator-runtime
两个文件都加载为插件即可

myStart() {
        var self = this
        var childs = this.childs

        function sleep(s) {
            return new Promise(resolve => self.scheduleOnce(resolve, s));
        }

        async function a(){
            self.soundPlay(res.s02)
            await sleep(2);
        }
        a()

        this.scheduleOnce(function () {
            this.nextPage()
        }, 7.2)
    }

参考:https://blog.csdn.net/qq_39043923/article/details/88662833
https://docs.cocos.com/creator/manual/zh/scripting/plugin-scripts.html?h=async

相关文章

网友评论

      本文标题:cocos creater使用 async , await

      本文链接:https://www.haomeiwen.com/subject/wbscjctx.html