3
\$\begingroup\$

I am new to XNA programming and I loaded the background image using ContentManager as a Texture2D object.

The background image which I have is of size 480*320. I have kept the minimum game window size as 640*480. My question is how would i resize the background image to the size of the game window.

Thanks in advance!

\$\endgroup\$
4
\$\begingroup\$

Whatever size the destination rectangle is for any of the top 3 SpriteBatch.Draw functions is how large your image will appear on screen.

So try the below to automatically draw an image full screen.

SpriteBatch.Draw(background_texture, GraphicsDevice.Viewport.Bounds, Color.White);

Note this doesn't actually change the size of you image it just scales it to the specified size when rendered.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Wow that was a simple thing to do. Thanks a lot :) \$\endgroup\$ – Gamer Mar 8 '12 at 19:11
  • \$\begingroup\$ Welcome to the wonderful world of XNA :) \$\endgroup\$ – ClassicThunder Mar 8 '12 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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