Package | org.flixel |
Class | public class FlxTilemap |
Inheritance | FlxTilemap FlxObject FlxBasic Object |
Property | Defined By | ||
---|---|---|---|
acceleration : FlxPoint
How fast the speed of this object is changing. | FlxObject | ||
active : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup. | FlxBasic | ||
_ACTIVECOUNT : uint [static] | FlxBasic | ||
alive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive. | FlxBasic | ||
allowCollisions : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions. | FlxObject | ||
angle : Number
Set the angle of a sprite to rotate it. | FlxObject | ||
angularAcceleration : Number
How fast the spin speed should change. | FlxObject | ||
angularDrag : Number
Like drag but for spinning. | FlxObject | ||
angularVelocity : 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 | ||
cameras : Array
An array of camera objects that this object will use during draw(). | FlxBasic | ||
drag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied
when acceleration is not affecting the sprite. | FlxObject | ||
elasticity : Number
The bounciness of this object. | FlxObject | ||
exists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup. | FlxBasic | ||
flickering : Boolean [read-only]
Check to see if the object is still flickering. | FlxObject | ||
health : Number
Handy for storing health percentage or armor points or whatever. | FlxObject | ||
height : Number
The height of this object. | FlxObject | ||
heightInTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
| FlxTilemap | ||
ID : int
IDs seem like they could be pretty useful, huh?
They're not actually used for anything yet though. | FlxBasic | ||
ignoreDrawDebug : 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 | ||
immovable : Boolean
Whether an object will move/alter position after a collision. | FlxObject | ||
last : FlxPoint
Important variable for collision processing. | FlxObject | ||
mass : Number
The virtual mass of the object. | FlxObject | ||
maxAngular : Number
Use in conjunction with angularAcceleration for fluid spin speed control. | FlxObject | ||
maxVelocity : FlxPoint
If you are using acceleration, you can use maxVelocity with it
to cap the speed automatically (very useful!). | FlxObject | ||
moves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()). | FlxObject | ||
path : FlxPath
A reference to a path object. | FlxObject | ||
pathAngle : Number
The angle in degrees between this object and the next node, where 0 is directly upward, and 90 is to the right. | FlxObject | ||
pathSpeed : Number
The speed at which the object is moving on the path. | FlxObject | ||
scrollFactor : 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 | ||
solid : Boolean
Whether the object collides or not. | FlxObject | ||
totalTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
| FlxTilemap | ||
touching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts. | FlxObject | ||
velocity : FlxPoint
The basic speed of this object. | FlxObject | ||
visible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup. | FlxBasic | ||
_VISIBLECOUNT : uint [static] | FlxBasic | ||
wasTouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step. | FlxObject | ||
width : Number
The width of this object. | FlxObject | ||
widthInTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
| FlxTilemap | ||
x : Number
X position of the upper left corner of this object in world space. | FlxObject | ||
y : Number
Y position of the upper left corner of this object in world space. | FlxObject |
Property | Defined 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 | ||
_flicker : Boolean
Internal helper used for retro-style flickering. | FlxObject | ||
_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 | ||
_pathInc : int
Internal helper for node navigation, specifically yo-yo and backwards movement. | FlxObject | ||
_pathMode : uint
Internal tracker for path behavior flags (like looping, horizontal only, etc). | FlxObject | ||
_pathNodeIndex : int
Internal helper, tracks which node of the path this object is moving toward. | FlxObject | ||
_pathRotate : Boolean
Internal flag for whether hte object's angle should be adjusted to the path angle during path follow behavior. | FlxObject | ||
_point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
| FlxObject | ||
_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 |
Method | Defined 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 | ||
[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 | ||
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style. | FlxObject | ||
Call this function to lock the automatic camera to the map's edges. | FlxTilemap | ||
followPath(Path:FlxPath, Speed:Number = 100, Mode:uint, AutoRotate:Boolean = false):void
Call this function to give this object a path to follow. | FlxObject | ||
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 | ||
Retrieve the midpoint of this object in world coordinates. | FlxObject | ||
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 | ||
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 | ||
isTouching(Direction:uint):Boolean
Handy function for checking if this object is touching a particular surface. | FlxObject | ||
justTouched(Direction:uint):Boolean
Handy function for checking if this object is just landed on a particular surface. | FlxObject | ||
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 | ||
Check and see if this object is currently on screen. | FlxObject | ||
[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 | ||
[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 | ||
postUpdate():void [override]
Post-update is called right after update() on each object in the game loop. | FlxObject | ||
preUpdate():void [override]
Pre-update is called right before update() on each object in the game loop. | FlxObject | ||
Shoots a ray from the start point to the end point. | FlxTilemap | ||
reset(X:Number, Y:Number):void
Handy function for reviving game objects. | FlxObject | ||
revive():void
Handy function for bringing game objects "back to life". | FlxBasic | ||
[static]
The main collision resolution function in flixel. | FlxObject | ||
[static]
The X-axis component of the object separation process. | FlxObject | ||
[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 | ||
stopFollowingPath(DestroyPath:Boolean = false):void
Tells this object to stop following the path its on. | FlxObject | ||
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 |
Method | Defined By | ||
---|---|---|---|
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 | ||
updateMotion():void
Internal function for updating the position and speed of this object. | FlxObject | ||
updatePathMotion():void
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 |
Constant | Defined By | ||
---|---|---|---|
ALT : uint = 2 [static]
Better for levels with thick walls that look better with interior corner art. | FlxTilemap | ||
ANY : 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 | ||
CEILING : uint = 0x0100 [static]
Special-case constant meaning up, used mainly by allowCollisions and touching. | FlxObject | ||
DOWN : uint = 0x1000 [static]
Generic value for "down" Used by facing, allowCollisions, and touching. | FlxObject | ||
FLOOR : uint = 0x1000 [static]
Special-case constant meaning down, used mainly by allowCollisions and touching. | FlxObject | ||
LEFT : uint = 0x0001 [static]
Generic value for "left" Used by facing, allowCollisions, and touching. | FlxObject | ||
NONE : uint = 0 [static]
Special-case constant meaning no collisions, used mainly by allowCollisions and touching. | FlxObject | ||
OFF : uint = 0 [static]
No auto-tiling. | FlxTilemap | ||
OVERLAP_BIAS : Number = 4 [static]
Handy constant used during collision resolution (see separateX() and separateY()). | FlxObject | ||
PATH_BACKWARD : uint = 0x000001 [static]
Path behavior controls: move from the end of the path to the start then stop. | FlxObject | ||
PATH_FORWARD : uint = 0x000000 [static]
Path behavior controls: move from the start of the path to the end then stop. | FlxObject | ||
PATH_HORIZONTAL_ONLY : uint = 0x010000 [static]
Path behavior controls: ignores any vertical component to the path data, only follows side to side. | FlxObject | ||
PATH_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 | ||
PATH_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 | ||
PATH_VERTICAL_ONLY : uint = 0x100000 [static]
Path behavior controls: ignores any horizontal component to the path data, only follows up and down. | FlxObject | ||
PATH_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 | ||
RIGHT : uint = 0x0010 [static]
Generic value for "right" Used by facing, allowCollisions, and touching. | FlxObject | ||
UP : uint = 0x0100 [static]
Generic value for "up" Used by facing, allowCollisions, and touching. | FlxObject | ||
WALL : uint [static]
Special-case constant meaning only the left and right sides, used mainly by allowCollisions and touching. | FlxObject |
_buffers | property |
protected var _buffers:Array
Internal list of buffers, one for each camera, used for drawing the tilemaps.
_data | property |
protected var _data:Array
Internal representation of the actual tile data, as a large 1D array of integers.
_debugRect | property |
protected var _debugRect:Rectangle
Internal, used for rendering the debug bounding box display.
_debugTileNotSolid | property |
protected var _debugTileNotSolid:BitmapData
Internal, used for rendering the debug bounding box display.
_debugTilePartial | property |
protected var _debugTilePartial:BitmapData
Internal, used for rendering the debug bounding box display.
_debugTileSolid | property |
protected var _debugTileSolid:BitmapData
Internal, used for rendering the debug bounding box display.
_flashPoint | property |
protected var _flashPoint:Point
Rendering helper, minimize new object instantiation on repetitive methods.
_flashRect | property |
protected var _flashRect:Rectangle
Rendering helper, minimize new object instantiation on repetitive methods.
_lastVisualDebug | property |
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.
_rects | property |
protected var _rects:Array
Internal representation of rectangles, one for each tile in the entire tilemap, used to speed up drawing.
_startingIndex | property |
protected var _startingIndex:uint
Internal, used to sort of insert blank tiles in front of the tiles in the provided graphic.
_tileHeight | property |
protected var _tileHeight:uint
Internal, the height of a single tile.
_tileObjects | property |
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).
_tiles | property |
protected var _tiles:BitmapData
Internal reference to the bitmap data object that stores the original tile graphics.
_tileWidth | property |
protected var _tileWidth:uint
Internal, the width of a single tile.
auto | property |
public var auto:uint
Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).
heightInTiles | property |
public var heightInTiles:uint
Read-only variable, do NOT recommend changing after the map is loaded!
ImgAuto | property |
public static var ImgAuto:Class
ImgAutoAlt | property |
public static var ImgAutoAlt:Class
totalTiles | property |
public var totalTiles:uint
Read-only variable, do NOT recommend changing after the map is loaded!
widthInTiles | property |
public var widthInTiles:uint
Read-only variable, do NOT recommend changing after the map is loaded!
FlxTilemap | () | Constructor |
public function FlxTilemap()
The tilemap constructor just initializes some basic variables.
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.
|
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.
|
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.
|
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.
|
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.
|
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).
|
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).
|
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.
|
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.
|
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.
|
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.
|
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() .
|
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 |
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.
|
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.
|
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.
|
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).
|
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!
|
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.
|
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.
|
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.
|
ALT | Constant |
public static const ALT:uint = 2
Better for levels with thick walls that look better with interior corner art.
AUTO | Constant |
public static const AUTO:uint = 1
Good for levels with thin walls that don'tile need interior corner art.
OFF | Constant |
public static const OFF:uint = 0
No auto-tiling.