Esempio n. 1
0
        /// <summary>
        /// draws an X
        /// </summary>
        /// <param name="sb">this spritebatch</param>
        /// <param name="pos">the center location of the X</param>
        /// <param name="size">width of the X</param>
        public static void DrawX(this SpriteBatch sb, Vector2 pos, float size, LayerData layer)
        {
            Vector2 sizeVec = new Vector2(size / 2);

            DrawLine(sb, pos - sizeVec, pos + sizeVec, Color.Black, layer);
            sizeVec.Y = -sizeVec.Y;
            DrawLine(sb, pos - sizeVec, pos + sizeVec, Color.Black, layer);
        }
Esempio n. 2
0
 /// <summary>
 /// creates a new sprite data instance
 /// </summary>
 public SpriteData()
 {
     FrameIndex   = 0;
     Speed        = 1;
     LayerData    = new LayerData(0);
     Offset       = new Vector2(0, 0);
     Origin       = new Vector2(0, 0);
     Size         = new Vector2(0, 0);
     SpriteEffect = SpriteEffects.None;
     Source       = null;
 }
Esempio n. 3
0
 /// <summary>
 /// draws a rectangle
 /// </summary>
 /// <param name="sb">the spritebatch to draw to</param>
 /// <param name="a">top left</param>
 /// <param name="b">bottom right</param>
 /// <param name="color">color of rectangle</param>
 /// <param name="layer">layer to draw at</param>
 public static void DrawRectangle(this SpriteBatch sb, Vector2 a, Vector2 b, Color color, LayerData layer)
 {
     DrawRectangle(sb, a, b, color, layer.ActualLayer);
 }
Esempio n. 4
0
        /// <summary>
        /// draws a line to the spritebatch
        /// </summary>
        /// <param name="sb">this spritebatch</param>
        /// <param name="a">beginning point of the line</param>
        /// <param name="b">ending point of the line</param>
        /// <param name="color">color of the line</param>
        /// <param name="depth">layer to draw the line at</param>
        public static void DrawLine(this SpriteBatch sb, Vector2 a, Vector2 b, Color color, LayerData layer)
        {
            if (singlePixel == null)
            {
                singlePixel = new Texture2D(sb.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                singlePixel.SetData(new Color[] { Color.White });
            }
            Vector2 dist  = b - a;
            float   angle = (float)Math.Atan2(dist.Y, dist.X);

            sb.Draw(singlePixel, a, null, color, angle, Vector2.Zero, new Vector2(dist.Length(), 1), SpriteEffects.None, layer.ActualLayer);
        }