Exemplo n.º 1
0
 public TestSASimpleSprite()
     : base(SAGraphicManager.GetImage(_resource))
 {
     sourceRectangle = _sourceRectangle;
     position        = Vector2.Zero;
     color           = Color.White;
 }
Exemplo n.º 2
0
 /// <summary>
 /// 最简单,一张图片搞定所有
 /// </summary>
 public SAButton(string resource, Rectangle sourceRect, Vector2 pos, ClickDelegate clickDel)
 {
     Init();
     //TODO
     this.texture              = SAGraphicManager.GetImage(resource);
     this._sourceRectangles    = new Rectangle[3];
     this._sourceRectangles[2] = this._sourceRectangles[1] = this._sourceRectangles[0] = sourceRect;
     this._sizes       = new Vector2[3];
     this._sizes[2]    = this._sizes[1] = this._sizes[0] = new Vector2(sourceRect.Width, sourceRect.Height);
     this.position     = pos;
     this.ClickHandler = clickDel;
     Add();
 }
Exemplo n.º 3
0
 public SAActionSprite(string resource, Rectangle[] sourceRectangles, Vector2 position, Color color, int index)
 {
     this.texture           = SAGraphicManager.GetImage(resource);
     this._sourceRectangles = sourceRectangles;
     this._sizes            = new Vector2[this._sourceRectangles.Length];
     for (int i = 0; i < this._sourceRectangles.Length; i++)
     {
         this._sizes[i] = new Vector2(this._sourceRectangles[i].Width, this._sourceRectangles[i].Height);
     }
     this.position = position;
     this.color    = color;
     this.index    = index;
 }
Exemplo n.º 4
0
 public SASwitchButton(string resource, Rectangle[] sourceRects, Vector2 pos, SwitchDelegate switchDel, bool ifOn)
 {
     Init();
     //TODO
     if (ifOn)
     {
         index = 0;
         this.controlStatus = ControlStatus.On;
     }
     else
     {
         index = 2;
         this.controlStatus = ControlStatus.Off;
     }
     this.texture           = SAGraphicManager.GetImage(resource);
     this._sourceRectangles = new Rectangle[4];
     this._sizes            = new Vector2[4];
     this.position          = pos;
     this.switchHandler     = switchDel;
     #region 处理不同的数量
     if (sourceRects.Length == 2)
     {
         this._sourceRectangles[1] = this._sourceRectangles[0] = sourceRects[0];
         this._sourceRectangles[3] = this._sourceRectangles[2] = sourceRects[1];
         for (int i = 0; i < 4; i++)
         {
             this._sizes[i] = new Vector2(_sourceRectangles[i].Width, _sourceRectangles[i].Height);
         }
     }
     else if (sourceRects.Length == 3)
     {
         this._sourceRectangles[0] = sourceRects[0];
         this._sourceRectangles[1] = this._sourceRectangles[3] = sourceRects[1];
         this._sourceRectangles[2] = sourceRects[2];
         for (int i = 0; i < 4; i++)
         {
             this._sizes[i] = new Vector2(_sourceRectangles[i].Width, _sourceRectangles[i].Height);
         }
     }
     else if (sourceRects.Length == 4)
     {
         for (int i = 0; i < 4; i++)
         {
             this._sourceRectangles[i] = sourceRects[i];
             this._sizes[i]            = new Vector2(_sourceRectangles[i].Width, _sourceRectangles[i].Height);
         }
     }
     #endregion
     Add();
 }
Exemplo n.º 5
0
 public Bird()
 {
     this.texture           = SAGraphicManager.GetImage("Images/tile");
     this._sourceRectangles = new Rectangle[MAX_NUM];
     this._sizes            = new Vector2[MAX_NUM];
     this.scores            = new string[MAX_NUM];
     for (int i = 0; i < MAX_NUM; i++)
     {
         scores[i] = Math.Pow(2, i).ToString();
         this._sourceRectangles[i] = new Rectangle(10 + (i % 4) * 105, 10 + (i / 4) * 110, 101, 101);
     }
     for (int i = 0; i < MAX_NUM; i++)
     {
         this._sizes[i] = new Vector2(this._sourceRectangles[i].Width, this._sourceRectangles[i].Height);
     }
     this.position = new Vector2(5 + GameData.LEFT_TOP_X, 5 + 222 + GameData.LEFT_TOP_Y);
     this.color    = Color.White;
     this.index    = 0;
 }
Exemplo n.º 6
0
 /// <summary>
 /// 最全面
 /// </summary>
 public SAButton(string resource, Rectangle[] sourceRects, Vector2 pos, ClickDelegate clickDel)
 {
     Init();
     //TODO
     this.texture           = SAGraphicManager.GetImage(resource);
     this._sourceRectangles = new Rectangle[3];
     this._sizes            = new Vector2[3];
     this.position          = pos;
     this.ClickHandler      = clickDel;
     #region 处理不同的数量
     if (sourceRects.Length == 3)
     {
         this._sourceRectangles = sourceRects;
         for (int i = 0; i < 3; i++)
         {
             this._sizes[i] = new Vector2(_sourceRectangles[i].Width, _sourceRectangles[i].Height);
         }
     }
     else if (sourceRects.Length == 2)
     {
         this._sourceRectangles[2] = this._sourceRectangles[0] = sourceRects[0];
         this._sourceRectangles[1] = sourceRects[1];
         for (int i = 0; i < 3; i++)
         {
             this._sizes[i] = new Vector2(_sourceRectangles[i].Width, _sourceRectangles[i].Height);
         }
     }
     else
     {
         for (int i = 0; i < 3; i++)
         {
             this._sourceRectangles[i] = sourceRects[0];
             this._sizes[i]            = new Vector2(_sourceRectangles[i].Width, _sourceRectangles[i].Height);
         }
     }
     #endregion
     Add();
 }
Exemplo n.º 7
0
 public SASimpleSprite(string resource, Rectangle sourceRectangle, Vector2 position, Color color)
     : this(SAGraphicManager.GetImage(resource), sourceRectangle, position, color)
 {
 }
Exemplo n.º 8
0
 public SASimpleSprite(string resource)
     : this(SAGraphicManager.GetImage(resource))
 {
 }
Exemplo n.º 9
0
 public SASimpleSprite(string resource, Vector2 position)
     : this(SAGraphicManager.GetImage(resource), position)
 {
 }
Exemplo n.º 10
0
 public SAActionSprite(string resource, Rectangle[] sourceRectangles, Vector2[] sizes, Vector2 position, Color color)
     : this(SAGraphicManager.GetImage(resource), sourceRectangles, sizes, position, color, 0)
 {
 }