Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: C#  |  size: 0.83 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     public class DrawableComponent : Component
  2.     {
  3.         Entity entity;
  4.  
  5.         public Texture2D Texture
  6.         {
  7.             get;
  8.             set;
  9.         }
  10.  
  11.         public Color TextureColor
  12.         {
  13.             get;
  14.             set;
  15.         }
  16.  
  17.         public DrawableComponent(Entity e)
  18.             : base(e)
  19.         {
  20.             TextureColor = Color.White;
  21.         }
  22.  
  23.         public DrawableComponent(Entity e, Texture2D t)
  24.             : base(e)
  25.         {
  26.             Texture = t;
  27.             TextureColor = Color.White;
  28.         }
  29.  
  30.         public void Draw(GameTime gameTime)
  31.         {
  32.             Rectangle targetRectangle = new Rectangle(entity.posX, entity.posY, Texture.Width, Texture.Height);
  33.  
  34.             entity.spritebatch.Draw(Texture, targetRectangle, TextureColor);        
  35.         }
  36.  
  37.  
  38.     }