0

I'm trying to understand how to make Cocos Studio exported scenes run inside cocos2d js project. seems like there is no documentation at all. I tried to instantiate scene object in different ways

var scene = ccs.csLoader.createNode("res/MainScene.json");
// or
var scene = cc.load("res/MainScene.json");

//res/MainScene.json is declared in resources 100%

but scene variable always contains empty objects (node and action). I debugged load and createNode methods with step into feature and found that there is no proper parsers for scene. I've stuck and don't know where to go next.

Does anyone know for sure if Cocos Studio is compatible with Cocos 2d JS?

UPDATE here is the code I'm using to initialise the project

cc.game.onStart = function(){
    cc.view.enableRetina(cc.sys.os === cc.sys.OS_IOS ? true : false);
    cc.view.adjustViewPort(true);
    cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.SHOW_ALL);
resolution size
    cc.view.resizeWithBrowserSize(true);
    cc.LoaderScene.preload(g_resources, function () {
        var scene = ccs.load("res/MainScene.json");
        cc.director.runScene(scene.node);
    }, this);
};
cc.game.run();

it's autogenerated by setup.py script, I just replaced Scene creation code with load from json. after var scene = line of code scene object is null or undefined

heximal
  • 10,327
  • 5
  • 46
  • 69
  • Cocos changed api. Look my answer in this [Link](http://stackoverflow.com/questions/35035027/cocos2d-js-cant-load-json-file-exported-from-cocosstudio/35054806#35054806) – Dazlonar Feb 13 '16 at 03:53
  • Hi Dazlonar, I saw your answer, unfortunately it didn't help, I suspect I'm doing something absolutely wrong. could you please see my updated question? – heximal Feb 13 '16 at 15:06
  • ok, I think, I found the reason, the question you linked was helpful from this perspective. I found that JSON scene object structure generated by Cocos Studio I currently have doesn't match json mentioned in question you attached. It's crazy, why is it happening? – heximal Feb 13 '16 at 17:12
  • may be it's due to cocos engine version? however, I downloaded latest version 3.10 and the result is the same – heximal Feb 13 '16 at 17:28
  • I think i understand why you have a problem. You don't add "res/MainScene.json" to g_resources list in resource.js – Dazlonar Feb 14 '16 at 06:40
  • Find "resource.js" in project folder and add "res/MainScene.json" to res - var res = { HelloWorld_png : "res/HelloWorld.png", MainScene : "res/MainScene.json" }; It's needed to download your file – Dazlonar Feb 14 '16 at 07:02
  • Oh, you wrote "res/MainScene.json is declared in resources 100%". I miss this. If is true, i don't understand why its happens, maybe you using old cocos studio file provided as cocos sample. Try to create new CocosStudio project. – Dazlonar Feb 14 '16 at 07:16

0 Answers0