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

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

  • 相关阅读:
    支付宝生活号内置浏览器长按保存二维码
    Web前端发展史
    ES6语法
    Java多线程
    Java基础知识
    静态库和动态库的使用
    Gcc的使用
    Vim的使用
    力扣345. 反转字符串中的元音字母
    力扣605. 种花问题
  • 原文地址:https://www.cnblogs.com/jiajunjie/p/10922142.html
Copyright © 2011-2022 走看看