Cocos2D-JS can't load json file exported from CocosStudio

643 Views Asked by At

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

There are 1 best solutions below

1
On BEST ANSWER

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