Enrichir les sprites : textures, défilement, transformation, animation
CHAPITRE 6
111
Sprite sprite;
public ChapitreSix()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
ServiceHelper.Game = this;
Components.Add(new KeyboardService(this));
graphics.PreferredBackBufferWidth = 100;
graphics.PreferredBackBufferHeight= 100;
}
protected override void Initialize()
{
sprite = new Sprite(new Vector2(0, 0), new Rectangle(0, 0, 100, 100));
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
sprite.LoadContent(Content, "figure_6_13", 6);
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
sprite.Update(gameTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
sprite.Draw(spriteBatch);
spriteBatch.End();
base.Draw(gameTime);
}
}
=Labat FM.book Page 111 Vendredi, 19. juin 2009 4:01 16
Précédent

- 132/366

Suivant