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