dragonbones 远程加载

var imageUrl = texPngData.url;
var skeUrl = skeJsonData.url;
var atlasUrl = texJsonData.url;
// imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
// skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
// atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';

    cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
        if (error) {
            console.log(error)
        }
        else {
            cc.assetManager.loadRemote(imageUrl, (error, texture) => {
                if (error) {
                    console.log(error)
                }
                else {
                    var atlas = new dragonBones.DragonBonesAtlasAsset();
                    atlas._uuid = atlasUrl;
                    atlas.atlasJson = assets[0];
                    atlas.texture = texture;

                    var asset = new dragonBones.DragonBonesAsset();
                    asset._uuid = skeUrl;
                    asset.dragonBonesJson = assets[1];

                    this.dragonBone.dragonAtlasAsset = atlas;
                    this.dragonBone.dragonAsset = asset;
                    let data = asset._dragonBonesJsonData.armature[0];
                    if (!data) {
                        return;
                    }
                    this.dragonBone.armatureName = data.name;
                    this.animationName = data.animation[0].name;

                    // this.dragonBone.premultipliedAlpha = true;
                    // atlas.texture.setPremultiplyAlpha(true);
                }
            });
        }
    });

你可能感兴趣的:(dragonbones 远程加载)