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) {},
});