美文网首页
dragonbones 远程加载

dragonbones 远程加载

作者: 欧特雨 | 来源:发表于2020-12-15 15:41 被阅读0次

    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 远程加载

          本文链接:https://www.haomeiwen.com/subject/pqewgktx.html