Advertisement
Guest User

Sprite.cs

a guest
Apr 27th, 2010
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Graphics;
  8. using Microsoft.Xna.Framework.Content;
  9.  
  10. namespace Article_sprite
  11. {
  12.     class Sprite
  13.     {
  14.  
  15.         Vector2 position;
  16.         Texture2D texture;
  17.  
  18.         // Le constructeur
  19.         public Sprite(Vector2 position)
  20.         {
  21.             this.position = position;
  22.         }
  23.  
  24.         //Permet de récuperer la position de l'objet
  25.         public Vector2 Position
  26.         {
  27.             get { return position; }
  28.             set { position = value; }
  29.         }
  30.  
  31.         //Charge l'image selon son nom depuis le Content Manager
  32.         public void LoadContent(ContentManager content, string assetName)
  33.         {
  34.             texture = content.Load<Texture2D>(assetName);
  35.         }
  36.  
  37.         //Donne un mouvement de translation au sprite
  38.         public void Update(Vector2 translation)
  39.         {
  40.             position += translation;
  41.  
  42.         }
  43.  
  44.         //Affiche le sprite
  45.         public void Draw(SpriteBatch spriteBatch)
  46.         {
  47.             spriteBatch.Draw(texture, position, Color.White);
  48.         }
  49.  
  50.  
  51.  
  52.  
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement