Draw メソッドで使用される Rectangles は、Texture2D のどの部分を rendertarget のどの部分 (通常は画面) に描画するかを定義します。
たとえば、これがタイルセットの使用方法です。
class Tile
{
int Index;
Vector2 Position;
}
Texture2D tileset = Content.Load<Texture2D>("sometiles"); //128x128 of 32x32-sized tiles
Rectangle source = new Rectangle(0,0,32,32); //We set the dimensions here.
Rectangle destination = new Rectangle(0,0,32,32); //We set the dimensions here.
List<Tile> myLevel = LoadLevel("level1");
//the tileset is 4x4 tiles
in Draw:
spriteBatch.Begin();
foreach (var tile in myLevel)
{
source.Y = (int)((tile.Index / 4) * 32);
source.X = (tile.Index - source.Y) * 32;
destination.X = (int)tile.Position.X;
destination.Y = (int)tile.Position.Y;
spriteBatch.Draw(tileset, source, destination, Color.White);
}
spriteBatch.End();
仕事中に頭の上からこれを行っているため、draw-methodで使用される長方形の順序を混同した可能性があります。
編集; Source Rectangle のみを使用すると、画面の位置にテクスチャの一部のみを描画できます。一方、Destination のみを使用すると、テクスチャを任意の場所に合わせてスケーリングできます。