Exemplo n.º 1
0
        public void DrawSprite2(Sprite sprite)
        {
            float width  = Math.Abs(sprite.width / sprite.scaleX);
            float height = Math.Abs(sprite.height / sprite.scaleY);

            Vector2[] points = sprite.GetExtents();
            destPoints[0] = new PointF(points[0].x, points[0].y);
            destPoints[1] = new PointF(points[1].x, points[1].y);
            destPoints[2] = new PointF(points[3].x, points[3].y);
            //System.Drawing.Rectangle sourceRect = new System.Drawing.Rectangle(0, 0, (int)width, (int)height);

            float[] uvs = sprite.GetUVs();
            System.Drawing.Rectangle sourceRect = new System.Drawing.Rectangle((int)(uvs[0] * sprite.texture.width), (int)(uvs[1] * sprite.texture.height), (int)width, (int)height);
            graphics.DrawImage(sprite.texture.bitmap, destPoints, sourceRect, GraphicsUnit.Pixel);
        }