I'm trying to figure out the cocos2d Javascript environment. I'm using Cocos Studio v2.1 beta to generate a scene. Right now the scene just has a label so I can know if it worked. I publish it to a Cocos Code IDE project created by Cocos Studio. After some searching, it seems you can load any CSB as a Node by using:
var imported = ccs.csLoader.createNode("res/MainScene.csb");
Node seems to be the root object for a lot of different things. I'm looking for a way to take this Node and pass it a call to cc.director.runScene(imported);
I tried calling getScene()
but that seemed like a stretch. imported
shouldn't have a parent that's a Scene, it IS a scene. I have a main.js that looks like this:
cc.game.onStart = function(){
cc.view.adjustViewPort(true);
cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.SHOW_ALL);
cc.view.resizeWithBrowserSize(true);
//load resources
cc.LoaderScene.preload(g_resources, function () {
var imported = ccs.csLoader.createNode("res/MainScene.csb");
cc.director.runScene(imported);
}, this);
};
cc.game.run();
When I run the game, it crashes as soon as I run it. Here's the console output:
Console: listening on 0.0.0.0 : 6050
Console: listening on 0.0.0.0 : 6060
Ready for GLSL
Ready for OpenGL 2.0
{
gl.version: 2.1.0 - Build 8.15.10.2622
gl.supports_NPOT: true
cocos2d.x.version: cocos2d-x 3.3
cocos2d.x.compiled_with_profiler: false
cocos2d.x.build_type: DEBUG
cocos2d.x.compiled_with_gl_state_cache: true
gl.max_texture_size: 8192
gl.vendor: Intel
gl.renderer: Intel(R) HD Graphics
gl.max_texture_units: 16
gl.supports_ETC1: false
gl.supports_S3TC: true
gl.supports_ATITC: false
gl.supports_PVRTC: false
gl.supports_BGRA8888: false
gl.supports_discard_framebuffer: false
gl.supports_vertex_array_object: true
}
cocos2d: fullPathForFilename: No file found at script/jsb_debugger.jsc. Possible missing file.
cocos2d: fullPathForFilename: No file found at script/debugger/DevToolsUtils.jsc. Possible missing file.
cocos2d: fullPathForFilename: No file found at script/debugger/core/promise.jsc. Possible missing file.
cocos2d: fullPathForFilename: No file found at script/debugger/transport.jsc. Possible missing file.
cocos2d: fullPathForFilename: No file found at script/debugger/actors/root.jsc. Possible missing file.
cocos2d: fullPathForFilename: No file found at script/debugger/actors/script.jsc. Possible missing file.
cocos2d: fullPathForFilename: No file found at script/debugger/main.jsc. Possible missing file.
cocos2d: fullPathForFilename: No file found at script/jsb_boot.jsc. Possible missing file.
suffix = csb
textureSize = 0
classname = Node
size = 1
classname = Text
callBackName cannot be found
size = 0
child = 0882F950
The files listed as missing seem to be misnamed. Those files all exist except with .js extensions instead of .jsc.
The project did run fine when main.js had cc.director.runScene(new HelloWorldScene());
so it seems the project is mostly configured correctly.
I must be loading the Scene incorrectly. What am I doing wrong?