问题
I'm trying to load a json file exported from cocosstudio v2.3.2
var myScene = ccs.sceneReader.createNodeWithSceneFile('res/Scene.json');
I got this code from sample-cocos2d-js-scene-gui-master
The problem is, i get this error: Can't find the parser : undefined
How do i fix this issue?
I'm very new to using javascript and I hope someone can help me with this.
Thank you.
回答1:
try to use ccs.load("")
It's new api. This function returns table {node, action}
node it's your scene "node" and "action" it's a time line action it's optional.
Your code would look like this:
var sceneRes = ccs.load("res/Scene.json");
this.addChild(sceneRes.node);
And if you want use the action, just run it for node.
sceneRes.node.runAction(sceneRes.action);
sceneRes.action.gotoFrameAndPlay(0, true);
Hope this help, and sorry for my english
来源:https://stackoverflow.com/questions/35035027/cocos2d-js-cant-load-json-file-exported-from-cocosstudio