cc.Class({
extends: cc.Component,
properties: {
label: {
default: null,
type: cc.Label
},
// defaults, set visually when attaching this script to the Canvas
text: 'Hello, World!'
},
// use this for initialization
onLoad: function () {
this.label.string = this.text;
var spineNode = new cc.Node();
var skeleton = spineNode.addComponent(sp.Skeleton);
this.node.addChild(spineNode);
var image = "http://localhost:7456/resources/jf/jf.png";
var ske = "http://localhost:7456/resources/jf/jf.skel";
var atlas = "http://localhost:7456/resources/jf/jf.atlas";
cc.assetManager.loadAny([{ url: atlas, ext: '.txt' }, { url: ske, ext: '.bin' }], (error, assets) => {
if (error) {
console.log(error)
}
else {
cc.assetManager.loadRemote(image, (error, texture) => {
if (error) {
console.log(error)
}
else {
var asset = new sp.SkeletonData();
asset._nativeAsset = assets[1]
asset.atlasText = assets[0]
asset.textures = [texture];
asset.textureNames = ["jf/jf.png"];
skeleton.skeletonData = asset;
}
});
}
});
},
// called every frame
update: function (dt) {
},
});
这是我的测试代码
出现了下面错误
Simulator: JS: [ERROR]: Downloader: Failed to download http://localhost:7456/resources/jf/jf.atlas with status code (404) -3
Simulator: JS: [ERROR]: Downloader: Failed to download http://localhost:7456/resources/jf/jf.skel with status code (404) -3
Simulator: JS: [ERROR]: Downloader: Failed to download http://localhost:7456/resources/jf/jf.atlas with status code (404) -3
Simulator: JS: [ERROR]: Downloader: Failed to download http://localhost:7456/resources/jf/jf.skel with status code (404) -3
Simulator: ScriptEngine::cleanup begin …