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
  • 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, 2014 at 18:05
  • 1
    \$\begingroup\$ @Jaakko You should make that an actual answer. \$\endgroup\$
    – Anko
    Jun 30, 2014 at 21:01

0

You must log in to answer this question.

Browse other questions tagged .