I have created a background image for a game that is 300x135 pixels. When loaded into my game, I need it to start at point (0,0), which it does:
position = new Vector2(0, 0);
However I want to enlarge this image so it spreads to 1200x540 pixels, however I'm not quite sure how to do this, although I'm aware I'm meant to use a Rectangle
or something similar.
Here are the componets for my background image:
Vector2 position;
Texture2D texture;
If Monogame truly mimicked XNA, there should be a SpriteBatch.Draw(...)
overload with a destinationRectangle
parameter where you can set the size.
destinationRectangle
Type: Rectangle
A rectangle that specifies (in screen coordinates) the destination for drawing the sprite. If this rectangle is not the same size as the source rectangle, the sprite will be scaled to fit.
https://msdn.microsoft.com/en-us/library/ff433987.aspx
yourBatch.Draw(texture,
new Rectangle(position.X, position.Y, 1200, 540),
new Rectangle(0,0, texturesOriginalWidth, texturesOriginalHeight),
Color.White);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With