Merging other rube scenes into a world

General discussion about the R.U.B.E editor
Post Reply
seannybgoode
Posts: 4
Joined: Mon Dec 22, 2014 9:55 pm

Merging other rube scenes into a world

Post 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?
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: import other rube scenes into a world

Post 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.
seannybgoode
Posts: 4
Joined: Mon Dec 22, 2014 9:55 pm

Re: import other rube scenes into a world

Post 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.
Post Reply