Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

this question is primarily about farseer but as it is a wrapper around box2d i think it's relevant for both libraries.

I'm in the beginning of developing a simple platform game, and I'm stuck as to how i should use the World object in relation to my "levels". Should I create a new world for each level and load all the contents of my level into this new world. Or should I remove all objects from my world and load in the new contents of the new level?

Any help or suggestions are greatly appreciated.

share|improve this question
    
I should add that I'm using farseer version 3.2 –  Daniel Figueroa Sep 30 '11 at 13:46
    
It seems i should read the documentation (obviously) before posting questions. The Box2d manual states: "Box2D supports the creation of multiple worlds, but this is usually not necessesary or desireable." So I guess I'll just clear the world for each new level. I can't mark this question as answered for another seven hours. –  Daniel Figueroa Sep 30 '11 at 13:55
add comment

1 Answer 1

up vote 1 down vote accepted

It seems i should read the documentation (obviously) before posting questions. The Box2d manual states: "Box2D supports the creation of multiple worlds, but this is usually not necessesary or desireable." So I guess I'll just clear the world for each new level. I can't mark this question as answered for another seven hours. –

This part of the documentation signifies that it's not necessary or desirable to have two active instances of the World class at the same time.

When loading a new level you can just have the old world object garbage collected. You don't have to pull some fancy tricks to pass the world object from the old, now obsolete level object, to the newly loaded level object. Of course if your world object is static, or managed by something else than level. (Say a LevelManager or something) then clearing the world object and then adding all the new stuff to it is just as good (or maybe even better), but both approaches should not bring any noticeable changes.

Btw, I'm not sure how far you are with learning Farseer, but I do know that it's quite hard to find tutorials, a user called RabidLion updated my Farseer tutorial to Farseer 3 and added quite a few extra things so it might be worth looking at: http://roy-t.nl/index.php/2011/01/12/xna-farseer-platform-physics-tutorial-updated-to-farseer-3/

share|improve this answer
    
Thank you Roy for clearing that up to me. That makes it much easier. Actually I saw your tutorial earlier today, and also the updated version. Thank you for writing a good tutorial! –  Daniel Figueroa Sep 30 '11 at 17:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.