hello
i have created my level in rube which contains a bike and platform.
now i would like to keep the bike seperate in biks.json file and my level in level01.json separate.
now can i load both bike.json and level01.json at once together.
i tried but it was showing the last .json file loaded in the simulator.
loading two json
Re: loading two json
I will assume you are using C++ and using the b2dJson source code from github
The function b2dJson::readFromFile takes an optional parameter for a world to load the bodies into. If no parameter is given it will create a world to use, otherwise it will use an existing world that you pass to it:
When finding items in the scene, remember to use the correct json object to locate them, eg.:
The function b2dJson::readFromFile takes an optional parameter for a world to load the bodies into. If no parameter is given it will create a world to use, otherwise it will use an existing world that you pass to it:
Code: Select all
string errorMsg;
b2dJson json1;
b2World* world = json1.readFromFile( "level1.json", errorMsg );
b2dJson json2;
json2.readFromFile( world, "bike.json", errorMsg, world );
Code: Select all
b2Fixture* finishLine = json1.getFixtureByName( "finish" ); // use json1
b2Fixture* bikeFrame = json2.getFixtureByName( "frame" ); // use json2