cocos creator 如何使正在播放的动画不重置

调用播放动画方法,传入动画名

that._playerPlayAction("playerRun")

if条件判断是否正在播放传入动画,如果正在播放则return

    _playerPlayAction:function (name) {
        var anim = this._player.getChildByName("anim").getComponent(cc.Animation)
        if(anim.currentClip && anim.currentClip.name == name){
            return
        }        
        anim.play(name)
    },

你可能感兴趣的:(Cocos,Creator)