zoukankan      html  css  js  c++  java
  • 白鹭龙骨异步加载

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

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

  • 相关阅读:
    如何有效的遍历django的QuerySet
    python进程池剖析(三)
    python进程池剖析(二)
    python进程池剖析(一)
    条件变量signal与unlock的顺序
    智能指针与句柄类(四)
    解析正则 /(d)(?=(d{3})+.)/g
    原生JS实现增加删除class
    RN 热更新
    Windows下搭建IOS开发环境
  • 原文地址:https://www.cnblogs.com/jiajunjie/p/10922142.html
Copyright © 2011-2022 走看看