Best practices of object design using Box2D and RUBE

General discussion about the R.U.B.E editor
Post Reply
pwitulski
Posts: 8
Joined: Sat Aug 17, 2013 4:48 pm

Best practices of object design using Box2D and RUBE

Post by pwitulski »

Hello everyone,

I am fairly new to using Box2D and RUBE but I have a few questions about the actual designing of the objects in the world. The first is, are "objects" suppose to be made up of 1 body with multiple fixtures contained inside of it like how I thought originally or 1 body for every fixture that is a part of the "object". The reason why I am asking is because I thought the first way was how it is suppose to be and looking at examples it looks like its the other way around. Does it matter which way it is done? Any performance gains or loses?

Also, is there a z-order for the fixtures inside a body. It doesn't matter in the simulation really, its when applying images that it will be more important.

Thank you.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Best practices of object design using Box2D and RUBE

Post by iforce2d »

If fixtures need to be kept rigid relative to each other, they'll need to be on the same body. Otherwise, you can pretty much arrange them as you see fit. If you have a static body that never moves (typical of a 'ground' body) it's common to have a large number of fixtures on that.

Fixtures don't have a z-order, since Box2D does nothing to do with rendering. In RUBE you can set the 'render order' property of images to draw them in a certain order.
Post Reply