cc.loader.loadRes("spine/spineboy.json", function (err, spineboyzer) {
var myNode = new cc.Node("spineboy");
var spineBoy = new sp.Skeleton();
spineBoy.skeletonData = spineboyzer;
spineBoy.defaultAnimation = "walk";
console.log(spineBoy); // here SkeletonData is null
self.node.addChild(myNode);
});
I am setting valid setSkeletonData , I get error Uncaught TypeError: Cannot read property '_color' of null , but If i drag and drop the same json to my sp.skeleton component , spine animation is working fine.
Update 2: I also tried this
cc.loader.loadRes("spine/spineboy", function (err, jsonobj) {
var myNode = new cc.Node("powerup");
var spineBoy = new sp.Skeleton();
spineBoy.skeletonData = jsonobj;
console.log(spineBoy);
self.node.addChild(myNode);
});
I get Skeleton.js:374 Uncaught TypeError: this.skeletonData.getRuntimeData is not a function error
When I do this.getComponent(sp.Skeleton).skeletonData.getRuntimeData() in the browser, it works fine, but in the “Simulator” it gives Simulator: TypeError: [...].getRuntimeData is not a function at a: "[...].getRuntimeData()"
Maybe there’s some initialization lag happening between when it’s called in the browser and the simulator? I don’t have the implementation in front of me, so I’m only guessing.
If Cocos/Spine “overloads” the JSON data (that exists as .skeletonData/.skeletonJson) after we call this function, the function wouldn’t exist at that moment, like we’re seeing here.
In browser, skeleton.skeletonData returns a sp.spine.SkeletonData type object (like the documentation says it should). We can verify this by logging with JSON.stringify() and getting a circular reference error.
However, in the simulator, it returns what looks like the SkeletonData.skeletonJson (NOT the sp.spine.SkeletonData parent that it should be returning). I’m using JSON.stringify() to log this out since I’m not aware of any other ways to debug this “simulator”.