缓动系统

缓动系统是对Cocos-x的动作系统的再一层封装,使api更加好用,链式调用,具体使用时可以查看相关的api和具体参数


const {ccclass, property} = cc._decorator;

@ccclass
export default class TweenStudy extends cc.Component {


    start () 
    {
        let tw = new cc.Tween()
        tw.target(this.node).to(1,{position:cc.v2(100,100),rotation:360}) //属性定义多个同时进行
        .to(1,{position:cc.v2(0,200)})
        .call(this.callback.bind(this)) //回调函数
        .start()
    }

    callback()
    {
        let tw = new cc.Tween()
        tw.target(this.node)
        .delay(2) //延迟2s执行
        .repeat(10,new cc.Tween().by(1,{rotation:360})) //重复10次 repeatForever永久重复
        .call(()=>{console.log("执行完成")})
        .start()
    }
}

首页 我的博客
粤ICP备17103704号