溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Egret之龍骨事件

發(fā)布時(shí)間:2020-07-30 11:36:35 來源:網(wǎng)絡(luò) 閱讀:2252 作者:Aonaufly 欄目:開發(fā)技術(shù)

首先來上龍骨的自定義事件:

1,在動(dòng)畫制作中 , 選擇一個(gè)動(dòng)畫  , 選中事件層加一個(gè)關(guān)鍵幀

Egret之龍骨事件

可以看到我在第11幀添加了一個(gè)關(guān)鍵幀


2,在屬性面板中添加一個(gè)自定義事件

Egret之龍骨事件


核心代碼如下::

  /**
        * 展示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( "動(dòng)畫播放開始");
        }
        private loop_com(evt:dragonBones.ArmatureEvent)
        {
            console.log( "動(dòng)畫播放完一輪完成!");
        }
        private frame_event(evt:dragonBones.FrameEvent)
        {
            console.log( " 播放到了一個(gè)關(guān)鍵幀! 幀標(biāo)簽為:",evt.frameLabel);
        }

結(jié)果:

Egret之龍骨事件

關(guān)鍵: this.eff_robot.armature.addEventListener( dragonBones.FrameEvent.ANIMATION_FRAME_EVENT, this.frame_event,this);

當(dāng)我們?cè)贒ragonBones中加入了幀事件事 , 這個(gè)就會(huì)觸發(fā)。



添加音樂事件

Egret之龍骨事件


代碼:

  /**
        * 展示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("動(dòng)畫播放開始");
        }
        private loop_com(evt:dragonBones.ArmatureEvent)
        {
            console.log( "動(dòng)畫播放完一輪完成!");
        }
        private frame_event(evt:dragonBones.FrameEvent)
        {
            console.log( " 播放到了一個(gè)關(guān)鍵幀! 幀標(biāo)簽為:",evt.frameLabel);
        }
        private sound_event(evt:dragonBones.SoundEvent)
        {
            console.log( "音的值為:",evt.sound);
        }

結(jié)果:

Egret之龍骨事件

關(guān)鍵:

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動(dòng)作幀事件
      */ 
     private aniFrame(e:dragonBones.EgretEvent):void
     {
         if(e.data.name=="A")
         {
             this.attackCb();
         }
     }


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI