This project has moved. For the latest updates, please go here.

how to get/set World size?

Dec 16, 2010 at 8:07 PM

Hi, newbie question....

Dec 17, 2010 at 1:33 PM

Not at all... it is infinite in every direction. Use static bodies/fixtures (i suggest edge, loop or box shapes) to specify the outline of your world. It does not even have to be rectangular ;)

Dec 17, 2010 at 1:50 PM

Thank you. This question ocurred to me because I needed a way to translate World coords to Screen coords, just doing World.Width / Screen.Width. How do I know how many pixes represent 1 meter?

Dec 17, 2010 at 2:11 PM

That is totally up to you. It is tempting to think about everything in pixels. Farseer though is completly resolution independent. If your game has a fixed resolution you just have to decide on one scale like 1m equals 64px or 100px and then just scale all your drawing operations accordingly. Let's say 1m = 64px, then you have to take all position data from Farseer and multiply it by 64 to get your screen coordinates in pixels. It really is just a matter of multiplying and dividing position data with a constant factor, to transform from one coordinate system to another.

Alternatively you can create a scaling matrix and pass that to spriteBatch.Begin(...) and just work with Farseers coordinates. The whole concept of resolution independence is explained in-depth here

Dec 17, 2010 at 9:07 PM

Yes, im still a little confused about the whole thing....   I will try to understand this concept. Thanks a lot for you time.