I'm building a 2D platformer and I want to have different colour backgrounds for each level. I've made an object that when collided with, it places the character onto the next level by changing the player.Position
, like so...
protected override void Update(GameTime gameTime){
if (player.Bounds.Intersects(teleportObj.Bounds))
{
GraphicsDevice.Clear(Color.SlateGray); // fails to change bg color
player.Position = new Vector2(172, 0); // successfully changes character position
MediaPlayer.Play(dungeonSong); // successfully plays new song
MediaPlayer.IsRepeating = true; // successfully repeats new song
}
}
I have already set a background for the first level to begin with in the Game1's Draw()
function like this:
GraphicsDevice.Clear(Color.CornflowerBlue);
But when my player collides with teleportObj
, the background color doesn't change.