Uncaught RangeError: Offset is outside the bounds of the DataView
at DataView.getInt8 ()
at BinaryInput.478.BinaryInput.readByte (cocos2d-js-for-preview.js:88852)
at BinaryInput.478.BinaryInput.readInt (cocos2d-js-for-preview.js:88865)
at BinaryInput.478.BinaryInput.readString (cocos2d-js-for-preview.js:88890)
at SkeletonBinary.478.SkeletonBinary.readSkeletonData (cocos2d-js-for-preview.js:88234)
at sp_SkeletonData.getRuntimeData (cocos2d-js-for-preview.js:92454)
at sp_Skeleton._updateSkeletonData (cocos2d-js-for-preview.js:84531)
at sp_Skeleton.notify (cocos2d-js-for-preview.js:83987)
at sp_Skeleton.val.set [as skeletonData] (cocos2d-js-for-preview.js:46781)
at eval (eval at (quick_compile.js:238), :146:45)
确认一下spine版本,代码,2.4.3加载二进制我测过是没有问题的
spine版本是多少
好像要求是3.8 版本上吧
好的 谢谢大佬
麻烦大佬发下加载的代码
onLoad:function () {
this.spine = this.node.getComponent(sp.Skeleton);
var image = "testRobot/robot.png";
var ske = "testRobot/robot.bin";
var atlas = "testRobot/robot.atlas";
var self = this;
cc.resources.load(atlas, (error, atlasJson) => {
cc.resources.load(ske, (error, jsonBin) => {
cc.resources.load(image, (error, texture) => {
var asset = new sp.SkeletonData();
asset._nativeAsset = jsonBin;
asset.atlasText = atlasJson;
asset.textures = [texture];
asset.textureNames = ['robot.png'];
self.spine.skeleton.skeletonData = asset;
});
});
});
},
又是另外一种错了,现在spine版本是3.8以上了,下面是报错,
这样做的目的就是共用一个动作文件,节省资源,有10多个spine动作一样皮肤不一样
Uncaught TypeError: Cannot read property ‘buffer’ of undefined
** at sp_SkeletonData.set [as _nativeAsset] (cocos2d-js-for-preview.js:92391)**
** at eval (eval at (quick_compile.js:238), :32:30)**
** at cocos2d-js-for-preview.js:46976**
麻烦大佬了
二进制到处的spine,后缀名是.skel,你的.bin是你自己改的嘛
可以选择bin跟skel 2.3.4是直接可以加载
loadJsonBin(skeUrl, callback) {
if (CACHE.robotJsonBin == null) {
cc.loader.load({ url: skeUrl, type: “bin” }, function (err, spineJson) {
//console.log(spineJson);
console.log("==============="+spineJson);
let json1 = spineJson.slice(1, spineJson.length);
//console.log(json1);
// 微信模拟器和真机端spineJson是ArrayBuffer类型
// 需要转成Uint8Array(浏览器不需要转)
let jsonBin = new Uint8Array(json1);
//jsonBin.set([28],0);
jsonBin[0] = 28;
//console.log(jsonBin);
CACHE.robotJsonBin = jsonBin;
callback(jsonBin);
});
} else {
//console.log("USE CACHE BIN!!!!!!!!!!!!!!");
callback(CACHE.robotJsonBin);
}
}
其他相同的spine都是共用这一个.bin文件
