C# Класс XnaFlixel.FlxTilemap

This is a traditional tilemap display and collision class. It takes a string of comma-separated numbers and then associates those values with tiles from the sheet you pass in. It also includes some handy static parsers that can convert arrays or PNG files into strings that can be successfully loaded.
Наследование: FlxObject
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
ImgAuto Microsoft.Xna.Framework.Graphics.Texture2D
ImgAutoAlt Microsoft.Xna.Framework.Graphics.Texture2D
auto int
collideIndex int
drawIndex int
heightInTiles int
refresh bool
startingIndex int
totalTiles int
widthInTiles int

Защищенные свойства (Protected)

Свойство Тип Описание
_block FlxObject
_boundsVisible bool
_data int[]
_flashRect Microsoft.Xna.Framework.Rectangle
_flashRect2 Microsoft.Xna.Framework.Rectangle
_rects List
_screenCols int
_screenRows int
_tileBitmap Microsoft.Xna.Framework.Graphics.Texture2D
_tileHeight int
_tileWidth int

Открытые методы

Метод Описание
FlxTilemap ( ) : System

The tilemap constructor just initializes some basic variables.

Overlaps ( FlxObject Core ) : bool

Checks for overlaps between the provided object and any tiles above the collision index. @param Core The FlxObject you want to check against.

OverlapsPoint ( float X, float Y ) : bool

Checks to see if a point in 2D space overlaps a solid tile. @param X The X coordinate of the point. @param Y The Y coordinate of the point. @param PerPixel Not available in FlxTilemap, ignored. @return Whether or not the point overlaps this object.

OverlapsPoint ( float X, float Y, bool PerPixel ) : bool
PreCollide ( FlxObject Object ) : void

FlxU.collide() (and thus FlxObject.collide()) call this function each time two objects are compared to see if they collide. It doesn't necessarily mean these objects WILL collide, however. @param Object The FlxObject you're about to run into.

RefreshHulls ( ) : void

Called by FlxObject.updateMotion() and some constructors to rebuild the basic collision data for this object.

Render ( SpriteBatch spriteBatch ) : void

Draws the tilemap.

arrayToCSV ( int Data, int Width ) : string

Converts a one-dimensional array of tile data to a comma-separated string. @param Data An array full of integer tile references. @param Width The number of tiles in each row. @return A comma-separated string containing the level data in a FlxTilemap-friendly format.

bitmapToCSV ( Microsoft.Xna.Framework.Graphics.Texture2D bitmapData ) : string

Converts a BitmapData object to a comma-separated string. Black pixels are flagged as 'solid' by default, non-black pixels are set as non-colliding. Black pixels must be PURE BLACK. @param bitmapData A Texture2D, preferably black and white. @param Invert Load white pixels as solid instead. @return A comma-separated string containing the level data in a FlxTilemap-friendly format.

bitmapToCSV ( Microsoft.Xna.Framework.Graphics.Texture2D bitmapData, bool Invert ) : string
follow ( ) : void

Call this function to lock the automatic camera to the map's edges. @param Border Adjusts the camera follow boundary by whatever number of tiles you specify here. Handy for blocking off deadends that are offscreen, etc. Use a negative number to add padding instead of hiding the edges.

follow ( int Border ) : void
getTile ( int X, int Y ) : int

Check the value of a particular tile. @param X The X coordinate of the tile (in tiles, not pixels). @param Y The Y coordinate of the tile (in tiles, not pixels). @return A uint containing the value of the tile at this spot in the array.

getTileByIndex ( int Index ) : int

Get the value of a tile in the tilemap by index. @param Index The slot in the data array (Y/// widthInTiles + X) where this tile is stored. @return A uint containing the value of the tile at this spot in the array.

loadMap ( string MapData, Microsoft.Xna.Framework.Graphics.Texture2D TileGraphic ) : FlxTilemap

Load the tilemap with string data and a tile graphic. @param MapData A string of comma and line-return delineated indices indicating what order the tiles should go in. @param TileGraphic All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData. @param TileWidth The width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified. @param TileHeight The height of your tiles (e.g. 8) - defaults to width if unspecified. @return A pointer this instance of FlxTilemap, for chaining as usual :)

loadMap ( string MapData, Microsoft.Xna.Framework.Graphics.Texture2D TileGraphic, int TileWidth, int TileHeight ) : FlxTilemap
ray ( int StartX, int StartY, int EndX, int EndY, Vector2 Result, int Resolution ) : bool

Shoots a ray from the start point to the end point. If/when it passes through a tile, it stores and returns that point. @param StartX The X component of the ray's start. @param StartY The Y component of the ray's start. @param EndX The X component of the ray's end. @param EndY The Y component of the ray's end. @param Result A Point object containing the first wall impact. @param Resolution Defaults to 1, meaning check every tile or so. Higher means more checks! @return Whether or not there was a collision between the ray and a colliding tile.

setCallback ( int Tile, int Callback, int Range ) : void

Bind a function Callback(Core:FlxCore,X:uint,Y:uint,Tile:uint) to a range of tiles. @param Tile The tile to trigger the callback. @param Callback The function to trigger. Parameters should be (Core:FlxCore,X:uint,Y:uint,Tile:uint). @param Range If you want this callback to work for a bunch of different tiles, input the range here. Default value is 1.

setTile ( int X, int Y, int Tile ) : bool

Change the data and graphic of a tile in the tilemap. @param X The X coordinate of the tile (in tiles, not pixels). @param Y The Y coordinate of the tile (in tiles, not pixels). @param Tile The new integer data you wish to inject. @param UpdateGraphics Whether the graphical representation of this tile should change. @return Whether or not the tile was actually changed.

setTile ( int X, int Y, int Tile, bool UpdateGraphics ) : bool
setTileByIndex ( int Index, int Tile, bool UpdateGraphics ) : bool

Change the data and graphic of a tile in the tilemap. @param Index The slot in the data array (Y/// widthInTiles + X) where this tile is stored. @param Tile The new integer data you wish to inject. @param UpdateGraphics Whether the graphical representation of this tile should change. @return Whether or not the tile was actually changed.

Защищенные методы

Метод Описание
autoTile ( int Index ) : void

An internal function used by the binary auto-tilers. @param Index The index of the tile you want to analyze.

generateBoundingTiles ( ) : void

Generates a bounding box version of the tiles, flixel should call this automatically when necessary.

updateTile ( int Index ) : void

Internal function used in setTileByIndex() and the constructor to update the map. @param Index The index of the tile you want to update.

Описание методов

FlxTilemap() публичный Метод

The tilemap constructor just initializes some basic variables.
public FlxTilemap ( ) : System
Результат System

Overlaps() публичный Метод

Checks for overlaps between the provided object and any tiles above the collision index. @param Core The FlxObject you want to check against.
public Overlaps ( FlxObject Core ) : bool
Core FlxObject
Результат bool

OverlapsPoint() публичный Метод

Checks to see if a point in 2D space overlaps a solid tile. @param X The X coordinate of the point. @param Y The Y coordinate of the point. @param PerPixel Not available in FlxTilemap, ignored. @return Whether or not the point overlaps this object.
public OverlapsPoint ( float X, float Y ) : bool
X float
Y float
Результат bool

OverlapsPoint() публичный Метод

public OverlapsPoint ( float X, float Y, bool PerPixel ) : bool
X float
Y float
PerPixel bool
Результат bool

PreCollide() публичный Метод

FlxU.collide() (and thus FlxObject.collide()) call this function each time two objects are compared to see if they collide. It doesn't necessarily mean these objects WILL collide, however. @param Object The FlxObject you're about to run into.
public PreCollide ( FlxObject Object ) : void
Object FlxObject
Результат void

RefreshHulls() публичный Метод

Called by FlxObject.updateMotion() and some constructors to rebuild the basic collision data for this object.
public RefreshHulls ( ) : void
Результат void

Render() публичный Метод

Draws the tilemap.
public Render ( SpriteBatch spriteBatch ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
Результат void

arrayToCSV() публичный статический Метод

Converts a one-dimensional array of tile data to a comma-separated string. @param Data An array full of integer tile references. @param Width The number of tiles in each row. @return A comma-separated string containing the level data in a FlxTilemap-friendly format.
public static arrayToCSV ( int Data, int Width ) : string
Data int
Width int
Результат string

autoTile() защищенный Метод

An internal function used by the binary auto-tilers. @param Index The index of the tile you want to analyze.
protected autoTile ( int Index ) : void
Index int
Результат void

bitmapToCSV() публичный статический Метод

Converts a BitmapData object to a comma-separated string. Black pixels are flagged as 'solid' by default, non-black pixels are set as non-colliding. Black pixels must be PURE BLACK. @param bitmapData A Texture2D, preferably black and white. @param Invert Load white pixels as solid instead. @return A comma-separated string containing the level data in a FlxTilemap-friendly format.
public static bitmapToCSV ( Microsoft.Xna.Framework.Graphics.Texture2D bitmapData ) : string
bitmapData Microsoft.Xna.Framework.Graphics.Texture2D
Результат string

bitmapToCSV() публичный статический Метод

public static bitmapToCSV ( Microsoft.Xna.Framework.Graphics.Texture2D bitmapData, bool Invert ) : string
bitmapData Microsoft.Xna.Framework.Graphics.Texture2D
Invert bool
Результат string

follow() публичный Метод

Call this function to lock the automatic camera to the map's edges. @param Border Adjusts the camera follow boundary by whatever number of tiles you specify here. Handy for blocking off deadends that are offscreen, etc. Use a negative number to add padding instead of hiding the edges.
public follow ( ) : void
Результат void

follow() публичный Метод

public follow ( int Border ) : void
Border int
Результат void

generateBoundingTiles() защищенный Метод

Generates a bounding box version of the tiles, flixel should call this automatically when necessary.
protected generateBoundingTiles ( ) : void
Результат void

getTile() публичный Метод

Check the value of a particular tile. @param X The X coordinate of the tile (in tiles, not pixels). @param Y The Y coordinate of the tile (in tiles, not pixels). @return A uint containing the value of the tile at this spot in the array.
public getTile ( int X, int Y ) : int
X int
Y int
Результат int

getTileByIndex() публичный Метод

Get the value of a tile in the tilemap by index. @param Index The slot in the data array (Y/// widthInTiles + X) where this tile is stored. @return A uint containing the value of the tile at this spot in the array.
public getTileByIndex ( int Index ) : int
Index int
Результат int

loadMap() публичный Метод

Load the tilemap with string data and a tile graphic. @param MapData A string of comma and line-return delineated indices indicating what order the tiles should go in. @param TileGraphic All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData. @param TileWidth The width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified. @param TileHeight The height of your tiles (e.g. 8) - defaults to width if unspecified. @return A pointer this instance of FlxTilemap, for chaining as usual :)
public loadMap ( string MapData, Microsoft.Xna.Framework.Graphics.Texture2D TileGraphic ) : FlxTilemap
MapData string
TileGraphic Microsoft.Xna.Framework.Graphics.Texture2D
Результат FlxTilemap

loadMap() публичный Метод

public loadMap ( string MapData, Microsoft.Xna.Framework.Graphics.Texture2D TileGraphic, int TileWidth, int TileHeight ) : FlxTilemap
MapData string
TileGraphic Microsoft.Xna.Framework.Graphics.Texture2D
TileWidth int
TileHeight int
Результат FlxTilemap

ray() публичный Метод

Shoots a ray from the start point to the end point. If/when it passes through a tile, it stores and returns that point. @param StartX The X component of the ray's start. @param StartY The Y component of the ray's start. @param EndX The X component of the ray's end. @param EndY The Y component of the ray's end. @param Result A Point object containing the first wall impact. @param Resolution Defaults to 1, meaning check every tile or so. Higher means more checks! @return Whether or not there was a collision between the ray and a colliding tile.
public ray ( int StartX, int StartY, int EndX, int EndY, Vector2 Result, int Resolution ) : bool
StartX int
StartY int
EndX int
EndY int
Result Vector2
Resolution int
Результат bool

setCallback() публичный Метод

Bind a function Callback(Core:FlxCore,X:uint,Y:uint,Tile:uint) to a range of tiles. @param Tile The tile to trigger the callback. @param Callback The function to trigger. Parameters should be (Core:FlxCore,X:uint,Y:uint,Tile:uint). @param Range If you want this callback to work for a bunch of different tiles, input the range here. Default value is 1.
public setCallback ( int Tile, int Callback, int Range ) : void
Tile int
Callback int
Range int
Результат void

setTile() публичный Метод

Change the data and graphic of a tile in the tilemap. @param X The X coordinate of the tile (in tiles, not pixels). @param Y The Y coordinate of the tile (in tiles, not pixels). @param Tile The new integer data you wish to inject. @param UpdateGraphics Whether the graphical representation of this tile should change. @return Whether or not the tile was actually changed.
public setTile ( int X, int Y, int Tile ) : bool
X int
Y int
Tile int
Результат bool

setTile() публичный Метод

public setTile ( int X, int Y, int Tile, bool UpdateGraphics ) : bool
X int
Y int
Tile int
UpdateGraphics bool
Результат bool

setTileByIndex() публичный Метод

Change the data and graphic of a tile in the tilemap. @param Index The slot in the data array (Y/// widthInTiles + X) where this tile is stored. @param Tile The new integer data you wish to inject. @param UpdateGraphics Whether the graphical representation of this tile should change. @return Whether or not the tile was actually changed.
public setTileByIndex ( int Index, int Tile, bool UpdateGraphics ) : bool
Index int
Tile int
UpdateGraphics bool
Результат bool

updateTile() защищенный Метод

Internal function used in setTileByIndex() and the constructor to update the map. @param Index The index of the tile you want to update.
protected updateTile ( int Index ) : void
Index int
Результат void

Описание свойств

ImgAuto публичное статическое свойство

public static Texture2D,Microsoft.Xna.Framework.Graphics ImgAuto
Результат Microsoft.Xna.Framework.Graphics.Texture2D

ImgAutoAlt публичное статическое свойство

public static Texture2D,Microsoft.Xna.Framework.Graphics ImgAutoAlt
Результат Microsoft.Xna.Framework.Graphics.Texture2D

_block защищенное свойство

protected FlxObject _block
Результат FlxObject

_boundsVisible защищенное свойство

protected bool _boundsVisible
Результат bool

_data защищенное свойство

protected int[] _data
Результат int[]

_flashRect защищенное свойство

Rendering helper.
protected Rectangle,Microsoft.Xna.Framework _flashRect
Результат Microsoft.Xna.Framework.Rectangle

_flashRect2 защищенное свойство

protected Rectangle,Microsoft.Xna.Framework _flashRect2
Результат Microsoft.Xna.Framework.Rectangle

_rects защищенное свойство

protected List _rects
Результат List

_screenCols защищенное свойство

protected int _screenCols
Результат int

_screenRows защищенное свойство

protected int _screenRows
Результат int

_tileBitmap защищенное свойство

protected Texture2D,Microsoft.Xna.Framework.Graphics _tileBitmap
Результат Microsoft.Xna.Framework.Graphics.Texture2D

_tileHeight защищенное свойство

protected int _tileHeight
Результат int

_tileWidth защищенное свойство

protected int _tileWidth
Результат int

auto публичное свойство

Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).
public int auto
Результат int

collideIndex публичное свойство

What tile index will you start colliding with (default: 1).
public int collideIndex
Результат int

drawIndex публичное свойство

What tile index will you start drawing with (default: 1) NOTE: should always be >= startingIndex. If you want to change it, do so before calling loadMap().
public int drawIndex
Результат int

heightInTiles публичное свойство

Read-only variable, do NOT recommend changing after the map is loaded!
public int heightInTiles
Результат int

refresh публичное свойство

Set this flag to true to force the tilemap buffer to refresh on the next render frame.
public bool refresh
Результат bool

startingIndex публичное свойство

The first index of your tile sheet (default: 0) If you want to change it, do so before calling loadMap().
public int startingIndex
Результат int

totalTiles публичное свойство

Read-only variable, do NOT recommend changing after the map is loaded!
public int totalTiles
Результат int

widthInTiles публичное свойство

Read-only variable, do NOT recommend changing after the map is loaded!
public int widthInTiles
Результат int