1
\$\begingroup\$

I have, in MonoGame, a project for which I require the game to not use the full screen depending on the resolution. The game elements etc all behave as they should (So they bounce off for example between 25% and 75% of the screen, instead of the edges). Yet I'm trying to draw a background between these two constraints, and it doesn't work.

To draw the background I am using the following code

spriteBatch.Draw(Background, new Rectangle(leftEdge,0,rightEdge,top),Color.White);

Yet when running the game, the image starts at "LeftEdge" but goes beyond "rightEdge". How would I go about scaling the image appropriately in this scenario?

\$\endgroup\$
  • 2
    \$\begingroup\$ The last two argument's in Rectangle's constructor are "width" and "height", not "right" and "top". So basically, put "rightEdge - leftEdge" as the third argument and it should work fine. \$\endgroup\$ – user9790 Jun 30 '14 at 18:05
  • 1
    \$\begingroup\$ @Jaakko You should make that an actual answer. \$\endgroup\$ – Anko Jun 30 '14 at 21:01

Your Answer

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

Browse other questions tagged or ask your own question.