Class AutoTiling
This class contains a DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) method that allows users to easily draw a tile with automatic connections, as well as a more complex DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float) method. Note that StaticSpriteBatch can also be used for drawing by using the AddAutoTile(StaticSpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float, ICollection<Item>) and AddExtendedAutoTile(StaticSpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float, ICollection<Item>) methods instead.
public static class AutoTiling
- Inheritance
-
AutoTiling
- Inherited Members
Methods
AddAutoTile(StaticSpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float, ICollection<Item>)
This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
For auto-tiling in this way to work, the tiles have to be laid out as follows: five tiles aligned horizontally within the texture file, with the following information:
- The texture used for filling big areas
- The texture used for straight, horizontal borders, with the borders facing away from the center
- The texture used for outer corners, with the corners facing away from the center
- The texture used for straight, vertical borders, with the borders facing away from the center
- The texture used for inner corners, with the corners facing away from the center
public static void AddAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion texture, AutoTiling.ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null)
Parameters
batch
StaticSpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
texture
TextureRegionThe texture to use for drawing, with the area set to the first texture region, as described in the summary.
connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
color
ColorThe color to draw with.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
items
ICollection<StaticSpriteBatch.Item>
AddExtendedAutoTile(StaticSpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float, ICollection<Item>)
This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:
- The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0, ICollection<StaticSpriteBatch.Item> items = null)
Parameters
batch
StaticSpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
backgroundTexture
TextureRegionThe background region, or null to skip drawing a background.
overlayTexture
TextureRegionThe first overlay region, as described in the summary.
connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
backgroundColor
ColorThe color to draw the texture used for filling big areas with.
overlayColor
ColorThe color to draw border and corner textures with.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
overlayDepthOffset
floatAn optional depth offset from
layerDepth
that the overlay should be drawn withitems
ICollection<StaticSpriteBatch.Item>
AddExtendedAutoTile(StaticSpriteBatch, Vector2, TextureRegion, Func<int, TextureRegion>, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float, ICollection<Item>)
This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:
- The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0, ICollection<StaticSpriteBatch.Item> items = null)
Parameters
batch
StaticSpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
backgroundTexture
TextureRegionThe background region, or null to skip drawing a background.
overlayTextures
Func<int, TextureRegion>connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
backgroundColor
ColorThe color to draw the texture used for filling big areas with.
overlayColor
ColorThe color to draw border and corner textures with.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
overlayDepthOffset
floatAn optional depth offset from
layerDepth
that the overlay should be drawn withitems
ICollection<StaticSpriteBatch.Item>
AddExtendedAutoTileCorner(StaticSpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float, ICollection<Item>)
This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)
public static void AddExtendedAutoTileCorner(StaticSpriteBatch batch, Vector2 pos, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null)
Parameters
batch
StaticSpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
overlayTexture
TextureRegionThe first overlay region, as described in the summary.
connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
overlayColor
ColorThe color to draw border and corner textures with.
corner
Direction2The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
items
ICollection<StaticSpriteBatch.Item>
AddExtendedAutoTileCorner(StaticSpriteBatch, Vector2, Func<int, TextureRegion>, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float, ICollection<Item>)
This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)
public static void AddExtendedAutoTileCorner(StaticSpriteBatch batch, Vector2 pos, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null)
Parameters
batch
StaticSpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
overlayTextures
Func<int, TextureRegion>connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
overlayColor
ColorThe color to draw border and corner textures with.
corner
Direction2The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
items
ICollection<StaticSpriteBatch.Item>
DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float)
This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
For auto-tiling in this way to work, the tiles have to be laid out as follows: five tiles aligned horizontally within the texture file, with the following information:
- The texture used for filling big areas
- The texture used for straight, horizontal borders, with the borders facing away from the center
- The texture used for outer corners, with the corners facing away from the center
- The texture used for straight, vertical borders, with the borders facing away from the center
- The texture used for inner corners, with the corners facing away from the center
public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion texture, AutoTiling.ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
texture
TextureRegionThe texture to use for drawing, with the area set to the first texture region, as described in the summary.
connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
color
ColorThe color to draw with.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)
This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:
- The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
backgroundTexture
TextureRegionThe background region, or null to skip drawing a background.
overlayTexture
TextureRegionThe first overlay region, as described in the summary.
connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
backgroundColor
ColorThe color to draw the texture used for filling big areas with.
overlayColor
ColorThe color to draw border and corner textures with.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
overlayDepthOffset
floatAn optional depth offset from
layerDepth
that the overlay should be drawn with
DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, Func<int, TextureRegion>, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)
This method allows for a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
This method is a more complex version of DrawAutoTile(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Vector2?, Vector2?, float) that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily. For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:
- The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
- The texture used for inner corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
backgroundTexture
TextureRegionThe background region, or null to skip drawing a background.
overlayTextures
Func<int, TextureRegion>connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
backgroundColor
ColorThe color to draw the texture used for filling big areas with.
overlayColor
ColorThe color to draw border and corner textures with.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
overlayDepthOffset
floatAn optional depth offset from
layerDepth
that the overlay should be drawn with
DrawExtendedAutoTileCorner(SpriteBatch, Vector2, TextureRegion, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float)
This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)
public static void DrawExtendedAutoTileCorner(SpriteBatch batch, Vector2 pos, TextureRegion overlayTexture, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
overlayTexture
TextureRegionThe first overlay region, as described in the summary.
connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
overlayColor
ColorThe color to draw border and corner textures with.
corner
Direction2The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.
DrawExtendedAutoTileCorner(SpriteBatch, Vector2, Func<int, TextureRegion>, ConnectsTo, Color, Direction2, Vector2?, Vector2?, float)
This method allows for a single corner of a tiled texture to be drawn in an auto-tiling mode. This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
For more information, and to draw all four corners at once, see DrawExtendedAutoTile(SpriteBatch, Vector2, TextureRegion, TextureRegion, ConnectsTo, Color, Color, Vector2?, Vector2?, float, float)
public static void DrawExtendedAutoTileCorner(SpriteBatch batch, Vector2 pos, Func<int, TextureRegion> overlayTextures, AutoTiling.ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0)
Parameters
batch
SpriteBatchThe sprite batch to use for drawing.
pos
Vector2The position to draw at.
overlayTextures
Func<int, TextureRegion>connectsTo
AutoTiling.ConnectsToA function that determines whether two positions should connect.
overlayColor
ColorThe color to draw border and corner textures with.
corner
Direction2The corner of the auto-tile to draw. Can be UpLeft, UpRight, DownLeft or DownRight.
origin
Vector2?The origin to draw from.
scale
Vector2?The scale to draw with.
layerDepth
floatThe layer depth to draw with.