Hi,
I was using sample loader for Cocos2D-x V3 and b2dJson "merging files into one world" functionality.
Does someone from you have sample loader for Cocos2D-JS or loader for Javasript with possibility to merge more json files together into one world? (I am aware of loadrube.js)
Thanks.
Sample loader for Cocos2D-JS
Re: Sample loader for Cocos2D-JS
In loadrube.js (I'll link for convenience: https://github.com/iforce2d/b2dJson/blo ... #L330-L332) you can see how a world is created and given as the target for loading into:
Although I have not tried it, you should be able to just do that as many times as you need to, giving the same world each time as the target to load into. For example:
I do see one problem that might come up though... I think only the images of the last loaded scene would be available after this process. You could try changing line 319 like this to address that (again, untested):
Code: Select all
var world = new b2World( gravity );
if ( ! loadSceneIntoWorld(worldJso, world) )
return false;
Code: Select all
var world = new b2World( gravity );
loadSceneIntoWorld(scene1, world);
loadSceneIntoWorld(scene2, world);
...
Code: Select all
// before
world.images = loadedImages;
// after
world.images = world.images.concat( loadedImages );