Midnight Blue Game and Engine
Public Member Functions | Properties | List of all members
MB2D.Tiles.TileMap Class Reference

A grid of tiles with collision. Wraps coordinates when they fall out of bounds. Allows accessing tiles by index. More...

Collaboration diagram for MB2D.Tiles.TileMap:
Collaboration graph

Public Member Functions

void Fill (Tile[,] tiles)
 Uses a 2D Array of previously defined tile information to fill a tile map with collision data and other information. Must be called in order for the TileMap to function. More...
 
 TileMap (Texture2D texture, int cellSize, int margin=0, int spacing=0, int offset=0, float scale=1.0f)
 Initializes a new instance of the T:MB2D.Tiles.TileMap class. Seperates the texture into a series of regions. More...
 
Rectangle GetTile (int id)
 Retrieves the bounding rectangle of a tile texture from the tilemap More...
 
void Draw (SpriteBatch spriteBatch)
 Draws the tile map to the specified SpriteBatch, wrapping the rendering when the camera reaches the bounds of the map. More...
 
void HandleWrapping (Movement movement)
 Handles wrapping an entity around the map if their movement falls out of bounds - gives the illusion of an infinitely looping map. More...
 

Properties

Tile this[int x, int y] [get]
 Gets the T:MB2D.Tiles.Tile at the specified x y. More...
 
Texture2D Texture [get]
 Gets the texture atlases undivided texture. More...
 
Point TileSize [get]
 Gets the size of each tile in the world. More...
 
Point MapSize [get]
 Gets the size of the map. More...
 

Detailed Description

A grid of tiles with collision. Wraps coordinates when they fall out of bounds. Allows accessing tiles by index.

Constructor & Destructor Documentation

§ TileMap()

MB2D.Tiles.TileMap.TileMap ( Texture2D  texture,
int  cellSize,
int  margin = 0,
int  spacing = 0,
int  offset = 0,
float  scale = 1.0f 
)
inline

Initializes a new instance of the T:MB2D.Tiles.TileMap class. Seperates the texture into a series of regions.

Parameters
textureTexture to use in the texture atlas.
cellSizeThe size of each cell in the texture atlas.
marginMargin to apply to each rendered tile.
spacingSpacing to apply to each rendered tile.
offsetOffset to apply to the x and y coordinates of each tile when rendering.
scaleScale vector to apply to each cell when rendering.

Member Function Documentation

§ Draw()

void MB2D.Tiles.TileMap.Draw ( SpriteBatch  spriteBatch)
inline

Draws the tile map to the specified SpriteBatch, wrapping the rendering when the camera reaches the bounds of the map.

Parameters
spriteBatchSprite batch to draw to.
Here is the caller graph for this function:

§ Fill()

void MB2D.Tiles.TileMap.Fill ( Tile  tiles[,])
inline

Uses a 2D Array of previously defined tile information to fill a tile map with collision data and other information. Must be called in order for the TileMap to function.

Parameters
tilesTiles.
Here is the caller graph for this function:

§ GetTile()

Rectangle MB2D.Tiles.TileMap.GetTile ( int  id)
inline

Retrieves the bounding rectangle of a tile texture from the tilemap

Returns
The tile ID's bounding rectangle.
Parameters
idThe ID to get.

§ HandleWrapping()

void MB2D.Tiles.TileMap.HandleWrapping ( Movement  movement)
inline

Handles wrapping an entity around the map if their movement falls out of bounds - gives the illusion of an infinitely looping map.

Parameters
movementMovement component to operate on.
Here is the caller graph for this function:

Property Documentation

§ MapSize

Point MB2D.Tiles.TileMap.MapSize
get

Gets the size of the map.

The size of the map.

§ Texture

Texture2D MB2D.Tiles.TileMap.Texture
get

Gets the texture atlases undivided texture.

The texture.

§ this[int x, int y]

Tile MB2D.Tiles.TileMap.this[int x, int y]
get

Gets the T:MB2D.Tiles.Tile at the specified x y.

Parameters
xThe x coordinate.
yThe y coordinate.

§ TileSize

Point MB2D.Tiles.TileMap.TileSize
get

Gets the size of each tile in the world.

The size of the tile.


The documentation for this class was generated from the following file: