This project has moved and is read-only. For the latest updates, please go here.

rectangle with bitmap texture

Topics: User Forum
Dec 6, 2008 at 7:20 PM
What is the code in Farseer to add a rectangle with a bitmap texture (jpg or bmp for example)?
Some can help me plzz
Dec 6, 2008 at 8:30 PM
If you download the XNA version with getting started samples, you can see it inside Demo2
Demo2 uses a DrawingHelper to create a rectangle texture. You can just remove that and load your own texture.
Dec 7, 2008 at 9:39 AM
Than you, but i can't do it.
I think that you want to say this, change (for example) Color.Gold with a texture, but the method receives a Color, then the compiler says that i'm wrong:
changing this            _rectangleTexture = DrawingHelper.CreateRectangleTexture(ScreenManager.GraphicsDevice, 128, 128, Color.Gold, Color.Black);
with            _rectangleTexture = DrawingHelper.CreateRectangleTexture(ScreenManager.GraphicsDevice, 128, 128,  BitmapTexture,   Color.Black);

My intention is load dinamically an image from file (.bmp, .jpg...) and apply this image texture to a rectangle (i'm too newbie in XNA and Farseer sorry).

Thanks again genbox.
Dec 7, 2008 at 11:44 AM
You need to use the ContentManager class from XNA to load textures. Our physics engine does not handle any graphics at all, it just does some physics calulations.

To load a texture using the ContentManager you do this:

_rectangleTexture = ScreenManager.ContentManager.Load<



The texture needs to be inside the Content folder in your project. That's it.
Dec 7, 2008 at 12:15 PM
Ok, this is the solution.