Egret之龙骨事件
admin
2023-02-17 16:00:02
0

首先来上龙骨的自定义事件:

1,在动画制作中 , 选择一个动画  , 选中事件层加一个关键帧

Egret之龙骨事件

可以看到我在第11帧添加了一个关键帧


2,在属性面板中添加一个自定义事件

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( "动画播放开始");
        }
        private loop_com(evt:dragonBones.ArmatureEvent)
        {
            console.log( "动画播放完一轮完成!");
        }
        private frame_event(evt:dragonBones.FrameEvent)
        {
            console.log( " 播放到了一个关键帧! 帧标签为:",evt.frameLabel);
        }

结果:

Egret之龙骨事件

关键: this.eff_robot.armature.addEventListener( dragonBones.FrameEvent.ANIMATION_FRAME_EVENT, this.frame_event,this);

当我们在DragonBones中加入了帧事件事 , 这个就会触发。



添加音乐事件

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("动画播放开始");
        }
        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);
        }

结果:

Egret之龙骨事件

关键:

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();
         }
     }


上一篇:Egret之JSZip基础

下一篇:Egret之龙骨换装

相关内容

热门资讯

终于了解“海贝大厅炸/金/花究... 有 亲,根据资深记者爆料海贝大厅炸/金/花是可以开挂的,确实有挂(咨询软...
今日重大消息“微信牛牛怎么装挂... 有 亲,根据资深记者爆料微信牛牛是可以开挂的,确实有挂(咨询软件无需打开...
终于了解“新永和炸/金/花究竟... 终于了解“新永和炸/金/花究竟有挂吗?”(外卦神器下载)您好,新永和炸/金/花这个游戏其实有挂的,确...
今日重磅消息“k3k吴江麻将到... 您好:k3k吴江麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这...
终于了解“十三十三水经典比鸡究... 终于了解“十三十三水经典比鸡究竟有挂吗?”(太坑了果然有挂)您好,十三十三水经典比鸡这个游戏其实有挂...
最新引进“开心麻花是不是有挂?... 网上科普关于“开心麻花有没有挂”话题很是火热,小编也是针对开心麻花作*弊开挂的方法以及开挂对应的知识...
【第一财经】“闽乐茶楼开挂器?... 网上科普关于“闽乐茶楼有没有挂”话题很是火热,小编也是针对闽乐茶楼作*弊开挂的方法以及开挂对应的知识...
【第一资讯】“暗宝到底是不是挂... 有 亲,根据资深记者爆料暗宝是可以开挂的,确实有挂(咨询软件无需打开直接...
最新引进“情怀麻将真的有挂吗?... 有 亲,根据资深记者爆料情怀麻将是可以开挂的,确实有挂(咨询软件无需打开...
终于懂了“七彩丹霞开挂神器?”... 您好:七彩丹霞这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款游戏...