美文网首页程序之路
Cocos Creator 定时器的使用

Cocos Creator 定时器的使用

作者: kingURL | 来源:发表于2019-01-15 17:21 被阅读0次

    以下是Ts代码:

    ''' 
        this.mIndex = 0;
        let funUp = function () {
            if (Index <= this.mIndex) {
                this.unschedule(funUp);
            }
        }
        this.schedule(funUp, newTime);
    '''
    

    条件一: 这个this.schedule(funUp, newTime); 是要写到一个继承组件的类的地方.
    条件二: 回调函数必须写成 let fun = function {...} 这样,才可以触发 this.unschedule(funDown) 这个,停止循环.

    最后标注一下,停止循环 unschedule 传的参数是回调函数,这个很奇特.

    相关文章

      网友评论

        本文标题:Cocos Creator 定时器的使用

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