[LayaAirIDE 2.0]龙骨动画的监听回调,有时能回调,有时不能回调

已邀请:

Veni vidi vici

赞同来自:

import GameConfig from "../../../GameConfig";
import { SingleBase } from "../../../lib/base/SingleBase";
import DdzFarmersAni from "./DdzFarmersAni"; 
export default class DdzLandlordAni extends SingleBase{
 
private mFactory: Laya.Templet = null;
public isFinish = false;
private mArmatureUsed:Array<Laya.Skeleton> = [];
private mArmatureUnUsed:Array<Laya.Skeleton> = []; 
public static getInstance():DdzLandlordAni{
return this.instance(DdzLandlordAni);

public constructor(){
super();
this.initTemplet();

public static destoryInstance(){
if(this.mInstance){
(<DdzLandlordAni>this.mInstance).destory();
this.mInstance = null;
}

public initTemplet(){
this.mFactory = new Laya.Templet();
this.mFactory.on(Laya.Event.COMPLETE, this, this.parseComplete);
// this.mFactory.on(Laya.Event.STOPPED,this,this.parseComplete);
this.mFactory.on(Laya.Event.ERROR, this, this.onError);
this.mFactory.loadAni("res/games/Game_ddz/animation/ddz_figures_landlord.sk");

 
private onError(): void {
console.log("error");

private parseComplete(): void {
console.error("地主加载完成");
this.isFinish = true;

public getArmature():Laya.Skeleton{
if(!this.isFinish){
return null;
}
let armature = null;
if(this.mArmatureUnUsed.length > 0){
armature = this.mArmatureUnUsed.pop();
}
if(this.mFactory){
armature = this.mFactory.buildArmature(0);
this.mArmatureUsed.push(armature);
return armature;
}

public recycleArmature(armature:Laya.Skeleton){
if(armature == null){
return;
}
armature.removeSelf();
this.mArmatureUnUsed.push(armature);

public playFail(armature:Laya.Skeleton){
if(armature == null){
return;
}
armature.play('fail',true);

public playStand(armature:Laya.Skeleton){
if(armature == null){
return;
}
armature.play('stand',true);

public playThinking(armature:Laya.Skeleton){
if(armature == null){
return;
}
armature.play('thinking',true);

public playWin(armature:Laya.Skeleton){
if(armature == null){
return;
}
armature.play('win',true);

public destory(){
console.log('销毁地主动画');
for(let i=0;i < this.mArmatureUnUsed.length;i++){
if(this.mArmatureUnUsed[i] != null){
this.mArmatureUnUsed[i].stop();//停止龙骨动画播放
this.mArmatureUnUsed[i].removeSelf();//从显示列表移除龙骨动画本身
this.mArmatureUnUsed[i].removeChildren();//从显示列表移除龙骨动画子对象
this.mArmatureUnUsed[i].destroy(true);//从显存销毁龙骨动画及其子对象
}
}
console.warn(this.mArmatureUsed.length);
for(let i=0;i < this.mArmatureUsed.length; i++){
if(this.mArmatureUsed[i] != null){
this.mArmatureUsed[i].stop();//停止龙骨动画播放
this.mArmatureUsed[i].removeSelf();//从显示列表移除龙骨动画本身
this.mArmatureUsed[i].removeChildren();//从显示列表移除龙骨动画子对象
// this.mArmatureUsed[i].destroy(true);//从显存销毁龙骨动画及其子对象
}
}
if(this.mFactory != null){
this.mFactory.destroy();//释放动画模板类下的纹理数据
this.mFactory = null;
}
}
}

要回复问题请先

商务合作
商务合作