zoukankan      html  css  js  c++  java
  • cocos 点击遍历播放该骨骼所有动画

    cc.Class({
        extends: cc.Component,
    
        properties: {
            _musicVolume: 1.0,
            _playEffect: [],
            _switchEffect: true
        },
    
        // LIFE-CYCLE CALLBACKS:
    
        onLoad () {
            this.arr = new Array();
            this.count = 0;
            this.node.on('touchstart',  (event) => {
                // 骨骼动画复制
                this.donghua = this.node.getChildByName("touch").getComponent(dragonBones.ArmatureDisplay);
                // 注册监听事件
                this.donghua.addEventListener(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this);
                // 播放第一个动画,动画结束时调监听事件
                this.donghua.playAnimation("walk",1);
                // 获取该骨骼所有动画名称
                this.arr = this.donghua.getAnimationNames("armatureName");
                cc.log("动画名称:" + this.arr);
    
            });
    
        },
    
        _animationEventHandler: function(event) {
            cc.log("动画开始播放 = " + this.arr[this.count]);
            this.donghua.playAnimation(this.arr[this.count],1);
            this.donghua.addEventListener(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this);
            this.count++;
            if (this.count>this.arr.length-1)
            {
                cc.log("动画已经全部播放!");
                // 播放结束以后,删除事件
                this.donghua.removeEventListener(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this);
                return ;
            }
        },
    
        
        start () {
    
        },
    
    
        // update (dt) {},
    });
  • 相关阅读:
    js验证身份证号,超准确
    C#对象序列化与反序列化
    寒冰王座[HDU1248]
    A C[HDU1570]
    循环多少次?[HDU1799]
    Play on Words[HDU1116]
    Fengshui-[SZU_B40]
    Travel Problem[SZU_K28]
    Big Event in HDU[HDU1171]
    Count the Trees[HDU1131]
  • 原文地址:https://www.cnblogs.com/Hunter-541695/p/9852891.html
Copyright © 2011-2022 走看看