白鹭龙骨异步加载

private armatureDisplay: dragonBones.EgretArmatureDisplay;
/**
* 加载龙骨动画
* Create scene interface
*/
private loadGragon(): void {
let t = this;
t.removeGragon();
//默认男战士
let sex = t.occupationSex.selectedValue ? t.occupationSex.selectedValue : 1;
let url1 = `resource/assets/gameui2/dragon/${sex == 1 ? "nan" : "nv"}zhanshi_ske.json`;
let url2 = `resource/assets/gameui2/dragon/${sex == 1 ? "nan" : "nv"}zhanshi_tex.json`;
let url3 = `resource/assets/gameui2/dragon/${sex == 1 ? "nan" : "nv"}zhanshi_tex.png`;
RES.getResByUrl(url1, t.createGragon, t, RES.NOCache);
RES.getResByUrl(url2, t.createGragon, t, RES.NOCache);
RES.getResByUrl(url3, t.createGragon, t, RES.NOCache);

}
dragonbonesData;
textureData;
texture;
temp = 0;
/**
* 创建龙骨动画
* Create scene interface
*/
private createGragon(data, url): void {
let t = this;
if (data.frameRate) {
t.dragonbonesData = data;
} else if (data.SubTexture) {
t.textureData = data;
} else if (data.bitmapData) {
t.texture = data;
}
if (t.temp == 0) {
t.temp++;
} else if (t.temp == 1) {
t.temp++;
} else if (t.temp == 2 && t.texture && t.textureData && t.dragonbonesData) {
t.temp = 0;
let egretFactory: dragonBones.EgretFactory = dragonBones.EgretFactory.factory;
if (!t.dragonbonesData) return;
egretFactory.parseDragonBonesData(t.dragonbonesData);
egretFactory.parseTextureAtlasData(t.textureData, t.texture);
let sex = t.occupationSex.selectedValue ? t.occupationSex.selectedValue : 1;
t.armatureDisplay = sex == 1 ? egretFactory.buildArmatureDisplay("armatureName") : egretFactory.buildArmatureDisplay("nvzhanshi");

t.armatureDisplay.x = sex == 1 ? 550 : 580;
t.armatureDisplay.y = sex == 1 ? 480 : 280;
t.armatureDisplay.scaleX = 0.5;
t.armatureDisplay.scaleY = 0.5;
t.armatureDisplay.animation.play("animation", 0);
t.mainGro.addChildAt(t.armatureDisplay, 2);
}
}

private removeGragon(): void {
let t = this;
if (t.armatureDisplay) {
t.armatureDisplay.animation.stop();
t.armatureDisplay.dispose();
t.armatureDisplay.removeSelf();
t.armatureDisplay = null;
}
}

/**适用类似创角界面这种用一次龙骨的界面,经常使用的,不用这么麻烦,直接按官网的教程做就行**/

转载于:https://www.cnblogs.com/jiajunjie/p/10922142.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值