Packageorg.flixel
Classpublic class FlxTilemap
InheritanceFlxTilemap Inheritance FlxObject Inheritance FlxBasic Inheritance Object

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 images into strings that can be loaded.



Public Properties
 PropertyDefined By
 Inheritedacceleration : FlxPoint
How fast the speed of this object is changing.
FlxObject
 Inheritedactive : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_ACTIVECOUNT : uint
[static]
FlxBasic
 Inheritedalive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive.
FlxBasic
 InheritedallowCollisions : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
FlxObject
 Inheritedangle : Number
Set the angle of a sprite to rotate it.
FlxObject
 InheritedangularAcceleration : Number
How fast the spin speed should change.
FlxObject
 InheritedangularDrag : Number
Like drag but for spinning.
FlxObject
 InheritedangularVelocity : Number
This is how fast you want this sprite to spin.
FlxObject
  auto : uint
Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).
FlxTilemap
 Inheritedcameras : Array
An array of camera objects that this object will use during draw().
FlxBasic
 Inheriteddrag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
FlxObject
 Inheritedelasticity : Number
The bounciness of this object.
FlxObject
 Inheritedexists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup.
FlxBasic
 Inheritedflickering : Boolean
[read-only] Check to see if the object is still flickering.
FlxObject
 Inheritedhealth : Number
Handy for storing health percentage or armor points or whatever.
FlxObject
 Inheritedheight : Number
The height of this object.
FlxObject
  heightInTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
FlxTilemap
 InheritedID : int
IDs seem like they could be pretty useful, huh? They're not actually used for anything yet though.
FlxBasic
 InheritedignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing when the visual debug mode in the debugger overlay is toggled on.
FlxBasic
  ImgAuto : Class
[static]
FlxTilemap
  ImgAutoAlt : Class
[static]
FlxTilemap
 Inheritedimmovable : Boolean
Whether an object will move/alter position after a collision.
FlxObject
 Inheritedlast : FlxPoint
Important variable for collision processing.
FlxObject
 Inheritedmass : Number
The virtual mass of the object.
FlxObject
 InheritedmaxAngular : Number
Use in conjunction with angularAcceleration for fluid spin speed control.
FlxObject
 InheritedmaxVelocity : FlxPoint
If you are using acceleration, you can use maxVelocity with it to cap the speed automatically (very useful!).
FlxObject
 Inheritedmoves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()).
FlxObject
 Inheritedpath : FlxPath
A reference to a path object.
FlxObject
 InheritedpathAngle : Number
The angle in degrees between this object and the next node, where 0 is directly upward, and 90 is to the right.
FlxObject
 InheritedpathSpeed : Number
The speed at which the object is moving on the path.
FlxObject
 InheritedscrollFactor : FlxPoint
A point that can store numbers from 0 to 1 (for X and Y independently) that governs how much this object is affected by the camera subsystem.
FlxObject
 Inheritedsolid : Boolean
Whether the object collides or not.
FlxObject
  totalTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
FlxTilemap
 Inheritedtouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts.
FlxObject
 Inheritedvelocity : FlxPoint
The basic speed of this object.
FlxObject
 Inheritedvisible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_VISIBLECOUNT : uint
[static]
FlxBasic
 InheritedwasTouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step.
FlxObject
 Inheritedwidth : Number
The width of this object.
FlxObject
  widthInTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
FlxTilemap
 Inheritedx : Number
X position of the upper left corner of this object in world space.
FlxObject
 Inheritedy : Number
Y position of the upper left corner of this object in world space.
FlxObject
Protected Properties
 PropertyDefined By
  _buffers : Array
Internal list of buffers, one for each camera, used for drawing the tilemaps.
FlxTilemap
  _data : Array
Internal representation of the actual tile data, as a large 1D array of integers.
FlxTilemap
  _debugRect : Rectangle
Internal, used for rendering the debug bounding box display.
FlxTilemap
  _debugTileNotSolid : BitmapData
Internal, used for rendering the debug bounding box display.
FlxTilemap
  _debugTilePartial : BitmapData
Internal, used for rendering the debug bounding box display.
FlxTilemap
  _debugTileSolid : BitmapData
Internal, used for rendering the debug bounding box display.
FlxTilemap
  _flashPoint : Point
Rendering helper, minimize new object instantiation on repetitive methods.
FlxTilemap
  _flashRect : Rectangle
Rendering helper, minimize new object instantiation on repetitive methods.
FlxTilemap
 Inherited_flicker : Boolean
Internal helper used for retro-style flickering.
FlxObject
 Inherited_flickerTimer : Number
Internal helper used for retro-style flickering.
FlxObject
  _lastVisualDebug : Boolean
Internal flag for checking to see if we need to refresh the tilemap display to show or hide the bounding boxes.
FlxTilemap
 Inherited_pathInc : int
Internal helper for node navigation, specifically yo-yo and backwards movement.
FlxObject
 Inherited_pathMode : uint
Internal tracker for path behavior flags (like looping, horizontal only, etc).
FlxObject
 Inherited_pathNodeIndex : int
Internal helper, tracks which node of the path this object is moving toward.
FlxObject
 Inherited_pathRotate : Boolean
Internal flag for whether hte object's angle should be adjusted to the path angle during path follow behavior.
FlxObject
 Inherited_point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
FlxObject
 Inherited_rect : FlxRect
This is just a pre-allocated rectangle container to be used however you like
FlxObject
  _rects : Array
Internal representation of rectangles, one for each tile in the entire tilemap, used to speed up drawing.
FlxTilemap
  _startingIndex : uint
Internal, used to sort of insert blank tiles in front of the tiles in the provided graphic.
FlxTilemap
  _tileHeight : uint
Internal, the height of a single tile.
FlxTilemap
  _tileObjects : Array
Internal collection of tile objects, one for each type of tile in the map (NOTE one for every single tile in the whole map).
FlxTilemap
  _tiles : BitmapData
Internal reference to the bitmap data object that stores the original tile graphics.
FlxTilemap
  _tileWidth : uint
Internal, the width of a single tile.
FlxTilemap
Public Methods
 MethodDefined By
  
The tilemap constructor just initializes some basic variables.
FlxTilemap
  
arrayToCSV(Data:Array, Width:int, Invert:Boolean = false):String
[static] Converts a one-dimensional array of tile data to a comma-separated string.
FlxTilemap
  
bitmapToCSV(bitmapData:BitmapData, Invert:Boolean = false, Scale:uint = 1):String
[static] Converts a BitmapData object to a comma-separated string.
FlxTilemap
  
destroy():void
[override] Clean up memory.
FlxTilemap
  
draw():void
[override] Draws the tilemap buffers to the cameras and handles flickering.
FlxTilemap
 Inherited
drawDebug(Camera:FlxCamera = null):void
[override] Override this function to draw custom "debug mode" graphics to the specified camera while the debugger's visual mode is toggled on.
FlxObject
  
findPath(Start:FlxPoint, End:FlxPoint, Simplify:Boolean = true, RaySimplify:Boolean = false):FlxPath
Find a path through the tilemap.
FlxTilemap
 Inherited
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
FlxObject
  
follow(Camera:FlxCamera = null, Border:int = 0, UpdateWorld:Boolean = true):void
Call this function to lock the automatic camera to the map's edges.
FlxTilemap
 Inherited
followPath(Path:FlxPath, Speed:Number = 100, Mode:uint, AutoRotate:Boolean = false):void
Call this function to give this object a path to follow.
FlxObject
  
getBounds(Bounds:FlxRect = null):FlxRect
Get the world coordinates and size of the entire tilemap as a FlxRect.
FlxTilemap
  
getData(Simple:Boolean = false):Array
Fetches the tilemap data array.
FlxTilemap
 Inherited
Retrieve the midpoint of this object in world coordinates.
FlxObject
 Inherited
getScreenXY(Point:FlxPoint = null, Camera:FlxCamera = null):FlxPoint
Call this function to figure out the on-screen position of the object.
FlxObject
  
getTile(X:uint, Y:uint):uint
Check the value of a particular tile.
FlxTilemap
  
getTileByIndex(Index:uint):uint
Get the value of a tile in the tilemap by index.
FlxTilemap
  
getTileCoords(Index:uint, Midpoint:Boolean = true):Array
Returns a new Flash Array full of every coordinate of the requested tile type.
FlxTilemap
  
getTileInstances(Index:uint):Array
Returns a new Flash Array full of every map index of the requested tile type.
FlxTilemap
 Inherited
hurt(Damage:Number):void
Reduces the "health" variable of this sprite by the amount specified in Damage.
FlxObject
  
imageToCSV(ImageFile:Class, Invert:Boolean = false, Scale:uint = 1):String
[static] Converts a resource image file to a comma-separated string.
FlxTilemap
 Inherited
isTouching(Direction:uint):Boolean
Handy function for checking if this object is touching a particular surface.
FlxObject
 Inherited
justTouched(Direction:uint):Boolean
Handy function for checking if this object is just landed on a particular surface.
FlxObject
 Inherited
kill():void
Handy function for "killing" game objects.
FlxBasic
  
loadMap(MapData:String, TileGraphic:Class, TileWidth:uint = 0, TileHeight:uint = 0, AutoTile:uint, StartingIndex:uint = 0, DrawIndex:uint = 1, CollideIndex:uint = 1):FlxTilemap
Load the tilemap with string data and a tile graphic.
FlxTilemap
 Inherited
onScreen(Camera:FlxCamera = null):Boolean
Check and see if this object is currently on screen.
FlxObject
  
overlaps(ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
[override] Checks to see if some FlxObject overlaps this FlxObject object in world space.
FlxTilemap
  
overlapsAt(X:Number, Y:Number, ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
[override] Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account.
FlxTilemap
  
overlapsPoint(Point:FlxPoint, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
[override] Checks to see if a point in 2D world space overlaps this FlxObject object.
FlxTilemap
  
overlapsWithCallback(Object:FlxObject, Callback:Function = null, FlipCallbackParams:Boolean = false, Position:FlxPoint = null):Boolean
Checks if the Object overlaps any tiles with any collision flags set, and calls the specified callback function (if there is one).
FlxTilemap
 Inherited
postUpdate():void
[override] Post-update is called right after update() on each object in the game loop.
FlxObject
 Inherited
preUpdate():void
[override] Pre-update is called right before update() on each object in the game loop.
FlxObject
  
ray(Start:FlxPoint, End:FlxPoint, Result:FlxPoint = null, Resolution:Number = 1):Boolean
Shoots a ray from the start point to the end point.
FlxTilemap
 Inherited
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
FlxObject
 Inherited
revive():void
Handy function for bringing game objects "back to life".
FlxBasic
 Inherited
separate(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The main collision resolution function in flixel.
FlxObject
 Inherited
separateX(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The X-axis component of the object separation process.
FlxObject
 Inherited
separateY(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The Y-axis component of the object separation process.
FlxObject
  
setDirty(Dirty:Boolean = true):void
Set the dirty flag on all the tilemap buffers.
FlxTilemap
  
setTile(X:uint, Y:uint, Tile:uint, UpdateGraphics:Boolean = true):Boolean
Change the data and graphic of a tile in the tilemap.
FlxTilemap
  
setTileByIndex(Index:uint, Tile:uint, UpdateGraphics:Boolean = true):Boolean
Change the data and graphic of a tile in the tilemap.
FlxTilemap
  
setTileProperties(Tile:uint, AllowCollisions:uint = 0x1111, Callback:Function = null, CallbackFilter:Class = null, Range:uint = 1):void
Adjust collision settings and/or bind a callback function to a range of tiles.
FlxTilemap
 Inherited
stopFollowingPath(DestroyPath:Boolean = false):void
Tells this object to stop following the path its on.
FlxObject
 Inherited
toString():String
Convert object to readable string name.
FlxBasic
  
update():void
[override] Main logic loop for tilemap is pretty simple, just checks to see if visual debug got turned on.
FlxTilemap
Protected Methods
 MethodDefined By
 Inherited
advancePath(Snap:Boolean = true):FlxPoint
Internal function that decides what node in the path to aim for next based on the behavior flags.
FlxObject
  
autoTile(Index:uint):void
An internal function used by the binary auto-tilers.
FlxTilemap
  
computePathDistance(StartIndex:uint, EndIndex:uint):Array
Pathfinding helper function, floods a grid with distance information until it finds the end point.
FlxTilemap
  
Internal function that actually renders the tilemap to the tilemap buffer.
FlxTilemap
  
makeDebugTile(Color:uint):BitmapData
Internal function to clean up the map loading code.
FlxTilemap
  
raySimplifyPath(Points:Array):void
Pathfinding helper function, strips out even more points by raycasting from one point to the next and dropping unnecessary points.
FlxTilemap
  
simplifyPath(Points:Array):void
Pathfinding helper function, strips out extra points on the same line.
FlxTilemap
 Inherited
Internal function for updating the position and speed of this object.
FlxObject
 Inherited
Internal function for moving the object along the path.
FlxObject
  
updateTile(Index:uint):void
Internal function used in setTileByIndex() and the constructor to update the map.
FlxTilemap
  
walkPath(Data:Array, Start:uint, Points:Array):void
Pathfinding helper function, recursively walks the grid and finds a shortest path back to the start.
FlxTilemap
Public Constants
 ConstantDefined By
  ALT : uint = 2
[static] Better for levels with thick walls that look better with interior corner art.
FlxTilemap
 InheritedANY : uint
[static] Special-case constant meaning any direction, used mainly by allowCollisions and touching.
FlxObject
  AUTO : uint = 1
[static] Good for levels with thin walls that don'tile need interior corner art.
FlxTilemap
 InheritedCEILING : uint = 0x0100
[static] Special-case constant meaning up, used mainly by allowCollisions and touching.
FlxObject
 InheritedDOWN : uint = 0x1000
[static] Generic value for "down" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedFLOOR : uint = 0x1000
[static] Special-case constant meaning down, used mainly by allowCollisions and touching.
FlxObject
 InheritedLEFT : uint = 0x0001
[static] Generic value for "left" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedNONE : uint = 0
[static] Special-case constant meaning no collisions, used mainly by allowCollisions and touching.
FlxObject
  OFF : uint = 0
[static] No auto-tiling.
FlxTilemap
 InheritedOVERLAP_BIAS : Number = 4
[static] Handy constant used during collision resolution (see separateX() and separateY()).
FlxObject
 InheritedPATH_BACKWARD : uint = 0x000001
[static] Path behavior controls: move from the end of the path to the start then stop.
FlxObject
 InheritedPATH_FORWARD : uint = 0x000000
[static] Path behavior controls: move from the start of the path to the end then stop.
FlxObject
 InheritedPATH_HORIZONTAL_ONLY : uint = 0x010000
[static] Path behavior controls: ignores any vertical component to the path data, only follows side to side.
FlxObject
 InheritedPATH_LOOP_BACKWARD : uint = 0x000100
[static] Path behavior controls: move from the end of the path to the start then directly back to the end, and start over.
FlxObject
 InheritedPATH_LOOP_FORWARD : uint = 0x000010
[static] Path behavior controls: move from the start of the path to the end then directly back to the start, and start over.
FlxObject
 InheritedPATH_VERTICAL_ONLY : uint = 0x100000
[static] Path behavior controls: ignores any horizontal component to the path data, only follows up and down.
FlxObject
 InheritedPATH_YOYO : uint = 0x001000
[static] Path behavior controls: move from the start of the path to the end then turn around and go back to the start, over and over.
FlxObject
 InheritedRIGHT : uint = 0x0010
[static] Generic value for "right" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedUP : uint = 0x0100
[static] Generic value for "up" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedWALL : uint
[static] Special-case constant meaning only the left and right sides, used mainly by allowCollisions and touching.
FlxObject
Protected Constants
 ConstantDefined By
 Inherited_pZero : FlxPoint
[static] Should always represent (0,0) - useful for different things, for avoiding unnecessary new calls.
FlxObject
Property Detail
_buffersproperty
protected var _buffers:Array

Internal list of buffers, one for each camera, used for drawing the tilemaps.

_dataproperty 
protected var _data:Array

Internal representation of the actual tile data, as a large 1D array of integers.

_debugRectproperty 
protected var _debugRect:Rectangle

Internal, used for rendering the debug bounding box display.

_debugTileNotSolidproperty 
protected var _debugTileNotSolid:BitmapData

Internal, used for rendering the debug bounding box display.

_debugTilePartialproperty 
protected var _debugTilePartial:BitmapData

Internal, used for rendering the debug bounding box display.

_debugTileSolidproperty 
protected var _debugTileSolid:BitmapData

Internal, used for rendering the debug bounding box display.

_flashPointproperty 
protected var _flashPoint:Point

Rendering helper, minimize new object instantiation on repetitive methods.

_flashRectproperty 
protected var _flashRect:Rectangle

Rendering helper, minimize new object instantiation on repetitive methods.

_lastVisualDebugproperty 
protected var _lastVisualDebug:Boolean

Internal flag for checking to see if we need to refresh the tilemap display to show or hide the bounding boxes.

_rectsproperty 
protected var _rects:Array

Internal representation of rectangles, one for each tile in the entire tilemap, used to speed up drawing.

_startingIndexproperty 
protected var _startingIndex:uint

Internal, used to sort of insert blank tiles in front of the tiles in the provided graphic.

_tileHeightproperty 
protected var _tileHeight:uint

Internal, the height of a single tile.

_tileObjectsproperty 
protected var _tileObjects:Array

Internal collection of tile objects, one for each type of tile in the map (NOTE one for every single tile in the whole map).

_tilesproperty 
protected var _tiles:BitmapData

Internal reference to the bitmap data object that stores the original tile graphics.

_tileWidthproperty 
protected var _tileWidth:uint

Internal, the width of a single tile.

autoproperty 
public var auto:uint

Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).

heightInTilesproperty 
public var heightInTiles:uint

Read-only variable, do NOT recommend changing after the map is loaded!

ImgAutoproperty 
public static var ImgAuto:Class

ImgAutoAltproperty 
public static var ImgAutoAlt:Class

totalTilesproperty 
public var totalTiles:uint

Read-only variable, do NOT recommend changing after the map is loaded!

widthInTilesproperty 
public var widthInTiles:uint

Read-only variable, do NOT recommend changing after the map is loaded!

Constructor Detail
FlxTilemap()Constructor
public function FlxTilemap()

The tilemap constructor just initializes some basic variables.

Method Detail
arrayToCSV()method
public static function arrayToCSV(Data:Array, Width:int, Invert:Boolean = false):String

Converts a one-dimensional array of tile data to a comma-separated string.

Parameters

Data:Array — An array full of integer tile references.
 
Width:int — The number of tiles in each row.
 
Invert:Boolean (default = false) — Recommended only for 1-bit arrays - changes 0s to 1s and vice versa.

Returns
String — A comma-separated string containing the level data in a FlxTilemap-friendly format.
autoTile()method 
protected function autoTile(Index:uint):void

An internal function used by the binary auto-tilers.

Parameters

Index:uint — The index of the tile you want to analyze.

bitmapToCSV()method 
public static function bitmapToCSV(bitmapData:BitmapData, Invert:Boolean = false, Scale:uint = 1):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.

Parameters

bitmapData:BitmapData — A Flash BitmapData object, preferably black and white.
 
Invert:Boolean (default = false) — Load white pixels as solid instead.
 
Scale:uint (default = 1) — Default is 1. Scale of 2 means each pixel forms a 2x2 block of tiles, and so on.

Returns
String — A comma-separated string containing the level data in a FlxTilemap-friendly format.
computePathDistance()method 
protected function computePathDistance(StartIndex:uint, EndIndex:uint):Array

Pathfinding helper function, floods a grid with distance information until it finds the end point. NOTE: Currently this process does NOT use any kind of fancy heuristic! It's pretty brute.

Parameters

StartIndex:uint — The starting tile's map index.
 
EndIndex:uint — The ending tile's map index.

Returns
Array — A Flash Array of FlxPoint nodes. If the end tile could not be found, then a null Array is returned instead.
destroy()method 
override public function destroy():void

Clean up memory.

draw()method 
override public function draw():void

Draws the tilemap buffers to the cameras and handles flickering.

drawTilemap()method 
protected function drawTilemap(Buffer:FlxTilemapBuffer, Camera:FlxCamera):void

Internal function that actually renders the tilemap to the tilemap buffer. Called by draw().

Parameters

Buffer:FlxTilemapBuffer — The FlxTilemapBuffer you are rendering to.
 
Camera:FlxCamera — The related FlxCamera, mainly for scroll values.

findPath()method 
public function findPath(Start:FlxPoint, End:FlxPoint, Simplify:Boolean = true, RaySimplify:Boolean = false):FlxPath

Find a path through the tilemap. Any tile with any collision flags set is treated as impassable. If no path is discovered then a null reference is returned.

Parameters

Start:FlxPoint — The start point in world coordinates.
 
End:FlxPoint — The end point in world coordinates.
 
Simplify:Boolean (default = true) — Whether to run a basic simplification algorithm over the path data, removing extra points that are on the same line. Default value is true.
 
RaySimplify:Boolean (default = false) — Whether to run an extra raycasting simplification algorithm over the remaining path data. This can result in some close corners being cut, and should be used with care if at all (yet). Default value is false.

Returns
FlxPath — A FlxPath from the start to the end. If no path could be found, then a null reference is returned.
follow()method 
public function follow(Camera:FlxCamera = null, Border:int = 0, UpdateWorld:Boolean = true):void

Call this function to lock the automatic camera to the map's edges.

Parameters

Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
 
Border:int (default = 0) — 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.
 
UpdateWorld:Boolean (default = true) — Whether to update the collision system's world size, default value is true.

getBounds()method 
public function getBounds(Bounds:FlxRect = null):FlxRect

Get the world coordinates and size of the entire tilemap as a FlxRect.

Parameters

Bounds:FlxRect (default = null) — Optional, pass in a pre-existing FlxRect to prevent instantiation of a new object.

Returns
FlxRect — A FlxRect containing the world coordinates and size of the entire tilemap.
getData()method 
public function getData(Simple:Boolean = false):Array

Fetches the tilemap data array.

Parameters

Simple:Boolean (default = false) — If true, returns the data as copy, as a series of 1s and 0s (useful for auto-tiling stuff). Default value is false, meaning it will return the actual data array (NOT a copy).

Returns
Array — An array the size of the tilemap full of integers indicating tile placement.
getTile()method 
public function getTile(X:uint, Y:uint):uint

Check the value of a particular tile.

Parameters

X:uint — The X coordinate of the tile (in tiles, not pixels).
 
Y:uint — The Y coordinate of the tile (in tiles, not pixels).

Returns
uint — A uint containing the value of the tile at this spot in the array.
getTileByIndex()method 
public function getTileByIndex(Index:uint):uint

Get the value of a tile in the tilemap by index.

Parameters

Index:uint — The slot in the data array (Y widthInTiles + X) where this tile is stored.

Returns
uint — A uint containing the value of the tile at this spot in the array.
getTileCoords()method 
public function getTileCoords(Index:uint, Midpoint:Boolean = true):Array

Returns a new Flash Array full of every coordinate of the requested tile type.

Parameters

Index:uint — The requested tile type.
 
Midpoint:Boolean (default = true) — Whether to return the coordinates of the tile midpoint, or upper left corner. Default is true, return midpoint.

Returns
Array — An Array with a list of all the coordinates of that tile type.
getTileInstances()method 
public function getTileInstances(Index:uint):Array

Returns a new Flash Array full of every map index of the requested tile type.

Parameters

Index:uint — The requested tile type.

Returns
Array — An Array with a list of all map indices of that tile type.
imageToCSV()method 
public static function imageToCSV(ImageFile:Class, Invert:Boolean = false, Scale:uint = 1):String

Converts a resource image file 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.

Parameters

ImageFile:Class — An embedded graphic, preferably black and white.
 
Invert:Boolean (default = false) — Load white pixels as solid instead.
 
Scale:uint (default = 1) — Default is 1. Scale of 2 means each pixel forms a 2x2 block of tiles, and so on.

Returns
String — A comma-separated string containing the level data in a FlxTilemap-friendly format.
loadMap()method 
public function loadMap(MapData:String, TileGraphic:Class, TileWidth:uint = 0, TileHeight:uint = 0, AutoTile:uint, StartingIndex:uint = 0, DrawIndex:uint = 1, CollideIndex:uint = 1):FlxTilemap

Load the tilemap with string data and a tile graphic.

Parameters

MapData:String — A string of comma and line-return delineated indices indicating what order the tiles should go in.
 
TileGraphic:Class — All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData.
 
TileWidth:uint (default = 0) — The width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified.
 
TileHeight:uint (default = 0) — The height of your tiles (e.g. 8) - defaults to width if unspecified.
 
AutoTile:uint (default = NaN) — Whether to load the map using an automatic tile placement algorithm. Setting this to either AUTO or ALT will override any values you put for StartingIndex, DrawIndex, or CollideIndex.
 
StartingIndex:uint (default = 0) — Used to sort of insert empty tiles in front of the provided graphic. Default is 0, usually safest ot leave it at that. Ignored if AutoTile is set.
 
DrawIndex:uint (default = 1) — Initializes all tile objects equal to and after this index as visible. Default value is 1. Ignored if AutoTile is set.
 
CollideIndex:uint (default = 1) — Initializes all tile objects equal to and after this index as allowCollisions = ANY. Default value is 1. Ignored if AutoTile is set. Can override and customize per-tile-type collision behavior using setTileProperties().

Returns
FlxTilemap — A pointer this instance of FlxTilemap, for chaining as usual :)
makeDebugTile()method 
protected function makeDebugTile(Color:uint):BitmapData

Internal function to clean up the map loading code. Just generates a wireframe box the size of a tile with the specified color.

Parameters

Color:uint

Returns
BitmapData
overlaps()method 
override public function overlaps(ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean

Checks to see if some FlxObject overlaps this FlxObject object in world space. If the group has a LOT of things in it, it might be faster to use FlxG.overlaps(). WARNING: Currently tilemaps do NOT support screen space overlap checks!

Parameters

ObjectOrGroup:FlxBasic — The object being tested.
 
InScreenSpace:Boolean (default = false) — Whether to take scroll factors into account when checking for overlap.
 
Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.

Returns
Boolean — Whether or not the two objects overlap.
overlapsAt()method 
override public function overlapsAt(X:Number, Y:Number, ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean

Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account. WARNING: Currently tilemaps do NOT support screen space overlap checks!

Parameters

X:Number — The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
 
Y:Number — The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
 
ObjectOrGroup:FlxBasic — The object or group being tested.
 
InScreenSpace:Boolean (default = false) — Whether to take scroll factors into account when checking for overlap. Default is false, or "only compare in world space."
 
Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.

Returns
Boolean — Whether or not the two objects overlap.
overlapsPoint()method 
override public function overlapsPoint(Point:FlxPoint, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean

Checks to see if a point in 2D world space overlaps this FlxObject object.

Parameters

Point:FlxPoint — The point in world space you want to check.
 
InScreenSpace:Boolean (default = false) — Whether to take scroll factors into account when checking for overlap.
 
Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.

Returns
Boolean — Whether or not the point overlaps this object.
overlapsWithCallback()method 
public function overlapsWithCallback(Object:FlxObject, Callback:Function = null, FlipCallbackParams:Boolean = false, Position:FlxPoint = null):Boolean

Checks if the Object overlaps any tiles with any collision flags set, and calls the specified callback function (if there is one). Also calls the tile's registered callback if the filter matches.

Parameters

Object:FlxObject — The FlxObject you are checking for overlaps against.
 
Callback:Function (default = null) — An optional function that takes the form "myCallback(Object1:FlxObject,Object2:FlxObject)", where Object1 is a FlxTile object, and Object2 is the object passed in in the first parameter of this method.
 
FlipCallbackParams:Boolean (default = false) — Used to preserve A-B list ordering from FlxObject.separate() - returns the FlxTile object as the second parameter instead.
 
Position:FlxPoint (default = null) — Optional, specify a custom position for the tilemap (useful for overlapsAt()-type funcitonality).

Returns
Boolean — Whether there were overlaps, or if a callback was specified, whatever the return value of the callback was.
ray()method 
public function ray(Start:FlxPoint, End:FlxPoint, Result:FlxPoint = null, Resolution:Number = 1):Boolean

Shoots a ray from the start point to the end point. If/when it passes through a tile, it stores that point and returns false.

Parameters

Start:FlxPoint — The world coordinates of the start of the ray.
 
End:FlxPoint — The world coordinates of the end of the ray.
 
Result:FlxPoint (default = null) — A Point object containing the first wall impact.
 
Resolution:Number (default = 1) — Defaults to 1, meaning check every tile or so. Higher means more checks!

Returns
Boolean — Returns true if the ray made it from Start to End without hitting anything. Returns false and fills Result if a tile was hit.
raySimplifyPath()method 
protected function raySimplifyPath(Points:Array):void

Pathfinding helper function, strips out even more points by raycasting from one point to the next and dropping unnecessary points.

Parameters

Points:Array — An array of FlxPoint nodes.

setDirty()method 
public function setDirty(Dirty:Boolean = true):void

Set the dirty flag on all the tilemap buffers. Basically forces a reset of the drawn tilemaps, even if it wasn'tile necessary.

Parameters

Dirty:Boolean (default = true) — Whether to flag the tilemap buffers as dirty or not.

setTile()method 
public function setTile(X:uint, Y:uint, Tile:uint, UpdateGraphics:Boolean = true):Boolean

Change the data and graphic of a tile in the tilemap.

Parameters

X:uint — The X coordinate of the tile (in tiles, not pixels).
 
Y:uint — The Y coordinate of the tile (in tiles, not pixels).
 
Tile:uint — The new integer data you wish to inject.
 
UpdateGraphics:Boolean (default = true) — Whether the graphical representation of this tile should change.

Returns
Boolean — Whether or not the tile was actually changed.
setTileByIndex()method 
public function setTileByIndex(Index:uint, Tile:uint, UpdateGraphics:Boolean = true):Boolean

Change the data and graphic of a tile in the tilemap.

Parameters

Index:uint — The slot in the data array (Y widthInTiles + X) where this tile is stored.
 
Tile:uint — The new integer data you wish to inject.
 
UpdateGraphics:Boolean (default = true) — Whether the graphical representation of this tile should change.

Returns
Boolean — Whether or not the tile was actually changed.
setTileProperties()method 
public function setTileProperties(Tile:uint, AllowCollisions:uint = 0x1111, Callback:Function = null, CallbackFilter:Class = null, Range:uint = 1):void

Adjust collision settings and/or bind a callback function to a range of tiles. This callback function, if present, is triggered by calls to overlap() or overlapsWithCallback().

Parameters

Tile:uint — The tile or tiles you want to adjust.
 
AllowCollisions:uint (default = 0x1111) — Modify the tile or tiles to only allow collisions from certain directions, use FlxObject constants NONE, ANY, LEFT, RIGHT, etc. Default is "ANY".
 
Callback:Function (default = null) — The function to trigger, e.g. lavaCallback(Tile:FlxTile, Object:FlxObject).
 
CallbackFilter:Class (default = null) — If you only want the callback to go off for certain classes or objects based on a certain class, set that class here.
 
Range:uint (default = 1) — If you want this callback to work for a bunch of different tiles, input the range here. Default value is 1.

simplifyPath()method 
protected function simplifyPath(Points:Array):void

Pathfinding helper function, strips out extra points on the same line.

Parameters

Points:Array — An array of FlxPoint nodes.

update()method 
override public function update():void

Main logic loop for tilemap is pretty simple, just checks to see if visual debug got turned on. If it did, the tilemap is flagged as dirty so it will be redrawn with debug info on the next draw call.

updateTile()method 
protected function updateTile(Index:uint):void

Internal function used in setTileByIndex() and the constructor to update the map.

Parameters

Index:uint — The index of the tile you want to update.

walkPath()method 
protected function walkPath(Data:Array, Start:uint, Points:Array):void

Pathfinding helper function, recursively walks the grid and finds a shortest path back to the start.

Parameters

Data:Array — A Flash Array of distance information.
 
Start:uint — The tile we're on in our walk backward.
 
Points:Array — A Flash Array of FlxPoint nodes composing the path from the start to the end, compiled in reverse order.

Constant Detail
ALTConstant
public static const ALT:uint = 2

Better for levels with thick walls that look better with interior corner art.

AUTOConstant 
public static const AUTO:uint = 1

Good for levels with thin walls that don'tile need interior corner art.

OFFConstant 
public static const OFF:uint = 0

No auto-tiling.