zoukankan      html  css  js  c++  java
  • egret---添加序列帧动画,帧包动画,龙骨动画

    1.添加序列帧动画,
      首先,写封装序列帧的ts

      然后在皮肤上用上,这个类名的组件,然后写上id,资源名,帧数,设置属性    自动播放为false,
      
      最后在指定地方调用

      public startGameAnimation:uiCore.Animation;
      this.startGameAnimation.play();
    2.帧包动画
    3.龙骨动画

      首先,写DragonAnim.ts,,怎么写呢,主要是白鹭本来就有dragonBones.d.ts类,然后,DragonAnim这个类就是调用这个库dragonBones.d.ts里面的方法。
      比如说,从指定帧开始播放指定的动画,gotoAndPlayByFrame(animationName:string,frame?:number,playTimes?:number):AnimationState | null ;
      简单来说,就是DragonAnim这里重新写一遍,

      private armatureDisplay:dragonBones.EgretArmatureDisplay;

      重点来啦,
        public static createDA(daName:string,autoPlay:boolean = true,playOnce:boolean = false):DragonAnim{
          var animator:DragonAnim = new DragonAnim();

          animator.animSource = daName;

          animator.autoPlay = autoPlay;

          animator.playOnce = playOnce;

          return animator;
        }

        public loadPri:number = 0;

        //资源根目录

        public animSource ="";

        //默认动画

        public defaultAnimationName:string = '';

        //自动播放

        public autoPlay:boolean = true;

        //播放一次

        public playOnce:boolean = false;

        //在停止状态下是否隐藏

        public stopLaterHide:boolean = false;

        //循环播放

        private loopNum:number = 0;

        

        给armatureDisplay添加资源名

        在舞台上添加armatureDisplay ()
      但是呢,要先判断一下,

      public setAnimSrc(animSrc:string,animName:string.loadFn?:()=>void,loadThis?:any):void{
        this.animSource = animSrc;

        this.animName = animName;

        if(!!this.animSource){

          this.setLoadFn(loadFn,loadThis);

          if(CoreConfig.isWebp && RES.hasRes(this.animSource + "_tex_webp")){

            this.imgSrc = this.animSource + "_tex_webp";

          }else{

            this.imgSrc = this.animSource + "_tex_png";

          }

          core.LoaderManager.instance([this.animSource + "_ske_json",this.animSource + "_tex_json" ,this.imgSrc],this,this.loadResComplete);

        }
      }
      if(this.armatureDisplay && this.armatureDisplay.animation){
        this.armatureDisplay.animation.gotoAndPlayByFrame(animationName,frame,playTimes);
      }

    public loadResComplete(){

      //加载资源的形式

    }
    //-------------------------------------------------------------------------------------------------------------------------
    但是我是这样写龙骨动画的:
    一般动画都是放在皮肤的一个组上:public gameEffectPanel:GameEffectPanel;
    class GameEffectPane extends uiCore.View{
      public constructor(){
        super();
        this.touchChildren = false;
      }
      public playGameAnimation(){
        let aniamtor = new core.DragonAnim();
        animator.horizontalCenter = anmator.verticalCenter = 0;

        animator.autoPlay = true;

        this.addChild(animator);

        animator.setAnimSrc(animatorSource,null);

        //一定要清除方法一

        animator.setOverFn(()=>{
          core.DisplayUtil.removeDisplay(animator);
        },this);
      }
    }


      


  • 相关阅读:
    AngularJS:模块
    AngularJS:事件
    AngularJS:HTML DOM
    AngularJS:SQL
    AngularJS:表格
    AngularJS:Select
    shell之数组
    java实现串中找数字
    java实现串的反转
    java实现串的反转
  • 原文地址:https://www.cnblogs.com/Lauren-J/p/10580405.html
Copyright © 2011-2022 走看看