由于项目需求,需要从远处服务器动态加载spine资源。就用官方2.4时候的例子:
var spineNode = new Node();
var skeleton = spineNode.addComponent(sp.Skeleton);
this.node.addChild(spineNode);
var image = "http://localhost/download/spineres/1/1.png";
var ske = "http://localhost/download/spineres/1/1.json";
var atlas = "http://localhost/download/spineres/1/1.atlas";
assetManager.loadAny([{ url: atlas, ext: '.txt' }, { url: ske, ext: '.txt' }], (error, assets) => {
assetManager.loadRemote<ImageAsset>(image, {type: 'png'}, function (err, imageAsset) {
const texture = new Texture2D();
texture.image = imageAsset;
var asset = new sp.SkeletonData();
asset.skeletonJson = assets[1];
asset.atlasText = assets[0];
asset.textures = [texture];
asset.textureNames = ['1.png'];
skeleton.skeletonData = asset;
});
});
在原生app会不断的报:
/Applications/CocosCreator/Creator/3.0.1/CocosCreator.app/Contents/Resources/resources/3d/cocos2d-x-lite/cocos/renderer/gfx-metal/MTLCommandBuffer.mm: line 452
17:05:42 [ERROR]: Sampler binding cc_spriteTexture at set 2 binding 10 is not bounded.