Du får ge lite kod, för det ska funka.
Här har du en minimal Game1 class som ändrar layer deth. Kolla om du missat något.
Kod:
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D texture;
Random random;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
texture = new Texture2D(GraphicsDevice, 1, 1);
texture.SetData(new Color[] { Color.White });
random = new Random();
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
spriteBatch.Draw(texture, new Rectangle(100, 100, 100, 100), null, Color.Blue, 0, Vector2.Zero, SpriteEffects.None, (float)random.NextDouble());
spriteBatch.Draw(texture, new Rectangle(150, 150, 100, 100), null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, (float)random.NextDouble());
spriteBatch.End();
base.Draw(gameTime);
}
}