cc.Class({
extends: cc.Component,
properties: {
dbboss: dragonBones.ArmatureDisplay
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
cc.log("gameloginnode + onLoad")
},
start () {
this.firstupdate = true
cc.log("gameloginnode + start")
this._armature = this.dbboss.armature();
//注册回调
this.dbboss.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this._animationEventHandler, this);//循环动画完成一次
this.dbboss.addEventListener(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this);//所有动画完成有限次数
},
_animationEventHandler: function (event) {
if (event.type === dragonBones.EventObject.LOOP_COMPLETE) {
cc.log("动画播放完成一次")
// if (event.animationState.name === "jump_1") {
// this._isJumpingB = true;
// this._speedY = -JUMP_SPEED;
// this._armature.animation.fadeIn("jump_2", -1, -1, 0, NORMAL_ANIMATION_GROUP);
// } else if (event.animationState.name === "jump_4") {
// this._updateAnimation();
// }
}
else if (event.type === dragonBones.EventObject.COMPLETE) {
cc.log("动画播放完成")
this._armature.animation.fadeIn("huxi", 0.3, 1);//没搞懂
//移出LOOP_COMPLETE 移出后 呼吸不会进入上面的回调了
this.dbboss.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this._animationEventHandler, this);
// if (event.animationState.name === "attack_01") {
// this._isAttackingB = false;
// this._attackState = null;
// }
}
},
update (dt) {
if (this.firstupdate) {
cc.log("gameloginnode + update")
this.firstupdate = false
}
},
});
网友评论