Reputation: 31
First post, first year programmer so go easy please.
When drawing a sprite in monogame, does anybody know how to make it stretch into the full screen?
For example I have my start screen appear but it doesnt stretch into the full screen (cause i have my window maximized when it opens). I've got "spriteBatch.Draw(startScreen, Vector2.Zero, null, Color.White);"
the null represents the rectangle property. does anybdoy know a word to replace null so that will stretch it?
This is in my load content for the texture:
startScreen = Content.Load<Texture2D>("Images/startGameSplash");
Then this is where I call it in my Draw Method:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
switch (gameState)
{
case GameState.StartScreen:
//draw the start screen
spriteBatch.Begin();
spriteBatch.Draw(startScreen, Vector2.Zero, null, Color.White);
//Drawing each rocket with another foreach
spriteBatch.End();
break;
case GameState.Running:
spriteBatch.Begin();
tank.Draw(spriteBatch);
foreach (BaseRocket shot in rocket) {
shot.Draw(spriteBatch);
}
spriteBatch.End();
break;
case GameState.EndScreen:
spriteBatch.Begin();
spriteBatch.Draw(endScreen, Vector2.Zero, null, Color.White);
spriteBatch.End();
break;
default:
break;
}
base.Draw(gameTime);
}
}
}
Thanks,
Upvotes: 3
Views: 1376
Reputation: 54248
From the source code / documentation of SpriteBatch
class of MonoGame, there is a Draw
function which accepts size as 2nd parameter:
public void Draw (Texture2D texture, Rectangle rectangle, Color color)
Assign the screen size rectangle to the parameter, and your sprite should fill the screen.
Upvotes: 4