首页 > 其他 > 详细

白鹭龙骨异步加载

时间:2019-05-25 13:36:23      阅读:112      评论:0      收藏:0      [点我收藏+]

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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!