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
파일 보기 프로젝트 열기: jsbeckr/XnaFlixel

공개 프로퍼티들

프로퍼티 타입 설명
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

보호된 프로퍼티들

프로퍼티 타입 설명
_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