spine 远程加载问题提问

cocos creator 2.4 版本如何远程加载二进制骨骼,目前按照官方的只会在web端生效,但在native端会出现crash。

let comp = this.getComponent('sp.Skeleton') as sp.Skeleton;

let image = "http://localhost/download/spineres/1/1.png";
let ske = "http://localhost/download/spineres/1/1.skel";
let atlas = "http://localhost/download/spineres/1/1.atlas";
assetManager.loadAny([{ url: atlas, ext: '.txt' }, { url: ske, ext: '.bin' }], (error, assets) => {
    assetManager.loadRemote(image, (error, img: ImageAsset) => {
        let texture = new Texture2D();
        texture.image = img;
        let asset = new sp.SkeletonData();
        asset._nativeAsset = assets[1];
        asset.atlasText = assets[0];
        asset.textures = [texture];
        asset.textureNames = ['1.png'];
        asset._uuid = ske; // 可以传入任意字符串,但不能为空
        asset._nativeURL = ske; // 传入一个二进制路径用作 initSkeleton 时的 filePath 参数使用
        comp.skeletonData = asset;
        let ani = comp.setAnimation(0, 'walk', true);
    });
});

碰到过这个问题,我记得原生端 textureNames 要与 atlas 中的文件名一致,比如说:
image
就要用 .textureNames = [“dianji.png”]

好,谢谢,我这里试试

此回帖给 后来(主要是2.x版本)的兄弟提个醒 :

楼主的例子 这里是3.8的例子 ,2.4 版本里,asset._nativeURL = ske; 里的 【_nativeURL 】 要写成 【_nativeUrl】,纯复制会害死人啊~

1赞