Page 1 of 1

Merging other rube scenes into a world

Posted: Mon Dec 22, 2014 10:14 pm
by seannybgoode
So I'm trying to set my team up for level editing. My implementation approach is to have images with custom properties define only the spawn location in RUBE, where our game engine will grab the object type name from the custom property and place it in-game.

I want to have a bunch of .rube files setup with simple images and the custom properties pre-arranged. For example, a player spawn location would have an image that says "player_spawn" and the custom properties all setup.

Is there any way I can import these into another RUBE scene that has our levels collision map?

Re: import other rube scenes into a world

Posted: Wed Dec 24, 2014 1:25 pm
by iforce2d
Do you mean import in your game program at runtime, or just import inside the RUBE editor program?

For importing at runtime, you could pass the existing world as a parameter to readFromFile, so that the newly loaded bodies are added to the same world instead of making a new one. This is mentioned in the main page for b2dJson, look for the section titled "Merging files into the same world". These threads might be helpful too:

Loading two json:
viewtopic.php?f=6&t=176

How to import a body set from another b2dworld?:
viewtopic.php?f=6&t=153

Make some bodies unload:
viewtopic.php?f=6&t=188

** update There is also some info on this at the main b2dJson page:
http://www.iforce2d.net/b2djson/#merging

For copying bodies between scenes inside the RUBE editor, you can select a set of bodies and use Ctrl+C to copy from one scene, and Ctrl+V to paste into another scene. After pasting the bodies will be selected so you can move/rotate them into place.

Re: import other rube scenes into a world

Posted: Thu Jan 08, 2015 10:27 pm
by seannybgoode
Yeah I mean in the editor, although I think we're going to have to load them at runtime with the way everything works.