Hi all (said the newbie). I've got a small question regarding Box2D performance. A short primer first:
I have a level map consisting of square blocks (all the same size). They're arranged into an array, so I need to create a body out of them. They are going to make up the static objects of a level, i.e. where the player object can walk over and can't pass through.
I see two ways to approach this:
Needless to say, having an array to work with the first solution is massively more easy for me because I can just create fixtures at the right places. For the second I will have to trace contours in the array and make sure I don't miss anything. I really only want to go there if I need to.
The question is this: which is the most efficient in terms of performance? It's fairly important to me as this uses a Javascript port of Box2D.
Thank you for your time!
I have a level map consisting of square blocks (all the same size). They're arranged into an array, so I need to create a body out of them. They are going to make up the static objects of a level, i.e. where the player object can walk over and can't pass through.
I see two ways to approach this:
- Create a ground body which has all the individual blocks as fixtures.
- Create a ground body which contains a number of chain edges as fixtures, in which groups adjacent blocks are placed inside a single closed chain edge. Since groups of adjacent blocks do not necessarily make up squares, a chain edge is not always a rectangle.
Needless to say, having an array to work with the first solution is massively more easy for me because I can just create fixtures at the right places. For the second I will have to trace contours in the array and make sure I don't miss anything. I really only want to go there if I need to.
The question is this: which is the most efficient in terms of performance? It's fairly important to me as this uses a Javascript port of Box2D.
Thank you for your time!