您好,登錄后才能下訂單哦!
首先來上龍骨的自定義事件:
1,在動畫制作中 , 選擇一個動畫 , 選中事件層加一個關鍵幀
可以看到我在第11幀添加了一個關鍵幀
2,在屬性面板中添加一個自定義事件
核心代碼如下::
/** * 展示Sheep特效 */ private showRoleWing(wingId: number): void { this.egretFactory = tools.DragonBoneTools.Instance.createEff2New( "Sheep_Ani_ske_json", "Sheep_Ani_tex_json", "Sheep_Ani_tex_png", ); this.eff_robot = this.egretFactory.buildArmatureDisplay("Armature"); this.addChild(this.eff_robot); this.eff_robot.animation.play("goat_eat_anim",0); this.eff_robot.x = 200; this.eff_robot.y = 450; this.eff_robot.armature.addEventListener( dragonBones.AnimationEvent.START, this.startPlay,this); this.eff_robot.armature.addEventListener( dragonBones.AnimationEvent.LOOP_COMPLETE, this.loop_com,this); this.eff_robot.armature.addEventListener( dragonBones.FrameEvent.ANIMATION_FRAME_EVENT, this.frame_event,this); //this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouch,this); } private startPlay(evt:dragonBones.ArmatureEvent) { console.log( "動畫播放開始"); } private loop_com(evt:dragonBones.ArmatureEvent) { console.log( "動畫播放完一輪完成!"); } private frame_event(evt:dragonBones.FrameEvent) { console.log( " 播放到了一個關鍵幀! 幀標簽為:",evt.frameLabel); }
結果:
關鍵: this.eff_robot.armature.addEventListener( dragonBones.FrameEvent.ANIMATION_FRAME_EVENT, this.frame_event,this);
當我們在DragonBones中加入了幀事件事 , 這個就會觸發。
添加音樂事件
代碼:
/** * 展示Sheep特效 */ private showRoleWing(wingId: number): void { this.egretFactory = tools.DragonBoneTools.Instance.createEff2New( "Sheep_Ani_ske_json", "Sheep_Ani_tex_json", "Sheep_Ani_tex_png", ); this.eff_robot = this.egretFactory.buildArmatureDisplay("Armature"); this.addChild(this.eff_robot); this.eff_robot.x = 200; this.eff_robot.y = 450; this.eff_robot.armature.addEventListener( dragonBones.AnimationEvent.START, this.startPlay,this); this.eff_robot.armature.addEventListener( dragonBones.AnimationEvent.LOOP_COMPLETE, this.loop_com,this); this.eff_robot.armature.addEventListener( dragonBones.FrameEvent.ANIMATION_FRAME_EVENT, this.frame_event,this); dragonBones.SoundEventManager.getInstance().addEventListener( dragonBones.SoundEvent.SOUND, this.sound_event,this); //this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouch,this); this.eff_robot.animation.play("goat_eat_anim",0); } private startPlay(evt:dragonBones.ArmatureEvent) { console.log("動畫播放開始"); } private loop_com(evt:dragonBones.ArmatureEvent) { console.log( "動畫播放完一輪完成!"); } private frame_event(evt:dragonBones.FrameEvent) { console.log( " 播放到了一個關鍵幀! 幀標簽為:",evt.frameLabel); } private sound_event(evt:dragonBones.SoundEvent) { console.log( "音的值為:",evt.sound); }
結果:
關鍵:
dragonBones.SoundEventManager.getInstance().addEventListener( dragonBones.SoundEvent.SOUND, this.sound_event,this);
更新事件
this._zhujueArm.addEventListener(dragonBones.EventObject.COMPLETE,this.comAttack,this); this._zhujueArm.addEventListener(dragonBones.EventObject.FRAME_EVENT,this.aniFrame,this); /** * boss動作幀事件 */ private aniFrame(e:dragonBones.EgretEvent):void { if(e.data.name=="A") { this.attackCb(); } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。