Enrichir les sprites : textures, défilement, transformation, animation
CHAPITRE 6
115
public Vector2 Position
{
get { return position; }
set { position = value; }
}
Texture2D texture;
public Texture2D Texture
{
get { return texture; }
}
Rectangle? sourceRectangle = null;
public Rectangle? SourceRectangle
{
get { return sourceRectangle; }
set { sourceRectangle = value; }
}
Color color = Color.White;
public Color Color
{
get { return color; }
set { color = value; }
}
public Sprite(Vector2 position, Rectangle? sourceRectangle)
{
this.position = position;
this.sourceRectangle = sourceRectangle;
}
public Sprite(Vector2 position, Rectangle? sourceRectangle, Color color)
{
this.position = position;
this.sourceRectangle = sourceRectangle;
this.color = color;
}
public void LoadContent(ContentManager content, string assetName)
{
texture = content.Load(assetName);
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, position, sourceRectangle, color);
}
}
=Labat FM.book Page 115 Vendredi, 19. juin 2009 4:01 16
Précédent

- 136/366

Suivant