私は現在、本「XNA 4.0 Game Development by Example」で、Gemstone Hunter を使用した TileMaping について学んでいます。299 ページで何をしているのかを説明していますが、今度は各メソッドが何をしているのかを示しています。いくつか質問がありますが、主な質問は、get と return は何をするのですか?:
誰にも解決を求めているわけではありませんが、get は何をしているのですか?
また、タイルシートが何をしているのか知りたいです。
MapWidth と MapHeight について教えてください。
(各作品が何をするかを知るためにコメントを書こうとしています)
#region Declarations
//TileWidth, and TileHeight are the size that each tile will be when playing and editing the game.
public const int TileWidth = 48;
public const int TileHeight = 48;
//MapWidth and MapHeight do... I don't know.
public const int MapWidth = 160;
public const int MapHeight = 12;
//MapLyaers represent the three back grounds in the MapSquare class.
public const int MapLayers = 3;
//skyTile is the blue tile that will be on the background, or the
private const int skyTile = 2;
//MapSquare organizes the tile sheet into map cells by width and height.
static private MapSquare[,] mapCells =
new MapSquare[MapWidth, MapHeight];
//Tells the the game if its playing or editing the maps.
public static bool EditorMode = true;
public static SpriteFont spriteFont;
static private Texture2D tileSheet;
#endregion
#region Initialization
//The Initialize() method establishes all of the MapCells as MapSquares with empty tiles on each layer.
//On back ground skyTile (2) will be the blue background, 0 will be transparent.
static public void Initialize(Texture2D tileTexture)
{
tileSheet = tileTexture;
for (int x = 0; x < MapWidth; x++)
{
for (int y = 0; y < MapHeight; y++)
{
for (int z = 0; z < MapLayers; z++)
{
mapCells[x, y] = new MapSquare(skyTile, 0, 0, "", true);
}
}
}
}
#endregion
#region Tile and Tile Sheet Handling
public static int TilesPerRow
{
get { return tileSheet.Width / TileWidth; }
}
public static Rectangle TileSourceRectangle(int tileIndex)
{
return new Rectangle(
(tileIndex % TilesPerRow) * TileWidth,
(tileIndex / TilesPerRow) * TileHeight,
TileWidth,
TileHeight);
}
#endregion