Package | org.flixel |
Class | public class FlxTilemap |
Inheritance | FlxTilemap ![]() ![]() ![]() |
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 | FlxTilemap | ||
collideIndex : uint
What tile index will you start colliding with (default: 1). | FlxTilemap | ||
![]() | drag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied
when acceleration is not affecting the sprite. | FlxObject | |
drawIndex : uint
What tile index will you start drawing with (default: 1) NOTE: should always be >= startingIndex. | FlxTilemap | ||
![]() | elasticity : Number | 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 | 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?
| FlxBasic | |
ImgAuto : Class [static] | FlxTilemap | ||
ImgAutoAlt : Class [static] | FlxTilemap | ||
![]() | immovable : Boolean
Whether an object will move/alter position after a collision. | FlxObject | |
![]() | last : FlxPoint | FlxObject | |
![]() | mass : Number | 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 | |
![]() | 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 | FlxObject | |
startingIndex : uint
The first index of your tile sheet (default: 0) If you want to change it, do so before calling loadMap(). | FlxTilemap | ||
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 and collision qualities. | 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 | FlxObject | |
![]() | width : Number | FlxObject | |
widthInTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
| FlxTilemap | ||
![]() | x : Number | FlxObject | |
![]() | y : Number | FlxObject |
Property | Defined By | ||
---|---|---|---|
_buffers : Array | FlxTilemap | ||
_callbacks : Array | FlxTilemap | ||
_data : Array | FlxTilemap | ||
_flashPoint : Point
Rendering helper. | FlxTilemap | ||
_flashRect : Rectangle | FlxTilemap | ||
![]() | _flicker : Boolean
Internal helper used for retro-style flickering. | FlxObject | |
![]() | _flickerTimer : Number
Internal helper used for retro-style flickering. | 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 | FlxTilemap | ||
_tileHeight : uint | FlxTilemap | ||
_tileObjects : Array | FlxTilemap | ||
_tiles : BitmapData | FlxTilemap | ||
_tileWidth : uint | 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] | FlxTilemap | ||
draw():void [override]
Draws 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 | ||
getData(Simple:Boolean = false):Array | FlxTilemap | ||
![]() | 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 | ||
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 | FlxObject | |
![]() | justTouched(Direction:uint):Boolean | FlxObject | |
![]() | kill():void | FlxBasic | |
loadMap(MapData:String, TileGraphic:Class, TileWidth:uint = 0, TileHeight:uint = 0):FlxTilemap
Load the tilemap with string data and a tile graphic. | FlxTilemap | ||
![]() | [override]
Check and see if this object is currently on screen. | FlxObject | |
[override]
Checks for overlaps between the provided object and any tiles above the collision index. | FlxTilemap | ||
overlapsPoint(X:Number, Y:Number, Camera:FlxCamera = null, PerPixel:Boolean = false):Boolean [override]
Checks to see if a point in 2D space overlaps a solid tile. | FlxTilemap | ||
overlapsWithCallback(Object:FlxObject, Callback:Function = null):Boolean | FlxTilemap | ||
![]() | postUpdate():void [override] | FlxObject | |
![]() | preUpdate():void [override] | FlxObject | |
ray(StartX:Number, StartY:Number, EndX:Number, EndY:Number, Result:FlxPoint, Resolution:Number = 1):Boolean
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 | FlxBasic | |
![]() | [static] | FlxObject | |
![]() | [static] | FlxObject | |
![]() | [static] | FlxObject | |
setDirty(Dirty:Boolean = true):void | 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, Range:uint = 1):void
Adjust collision settings and/or bind a callback function to a range of tiles. | FlxTilemap | ||
![]() | toString():String
Convert object to readable string name. | FlxBasic | |
![]() | update():void [override]
Called by the main game loop, handles motion/physics and game logic
| FlxObject |
Method | Defined By | ||
---|---|---|---|
autoTile(Index:uint):void
An internal function used by the binary auto-tilers. | FlxTilemap | ||
Internal function that actually renders the tilemap to the tilemap buffer. | FlxTilemap | ||
![]() | updateMotion():void
Internal function for updating the position and speed of this object. | FlxObject | |
updateTile(Index:uint):void
Internal function used in setTileByIndex() and the constructor to update the map. | FlxTilemap |
Constant | Defined By | ||
---|---|---|---|
ALT : uint = 2 [static]
Top-down auto-tiling. | FlxTilemap | ||
![]() | ANY : uint [static] | FlxObject | |
AUTO : uint = 1 [static]
Platformer-friendly auto-tiling. | FlxTilemap | ||
![]() | CEILING : uint = 0x0100 [static] | FlxObject | |
![]() | DOWN : uint = 0x1000 [static] | FlxObject | |
![]() | FLOOR : uint = 0x1000 [static] | FlxObject | |
![]() | LEFT : uint = 0x0001 [static] | FlxObject | |
![]() | NONE : uint = 0 [static] | FlxObject | |
OFF : uint = 0 [static]
No auto-tiling. | FlxTilemap | ||
![]() | OVERLAP_BIAS : Number = 4 [static] | FlxObject | |
![]() | RIGHT : uint = 0x0010 [static] | FlxObject | |
![]() | UP : uint = 0x0100 [static] | FlxObject | |
![]() | WALL : uint [static] | FlxObject |
_buffers | property |
protected var _buffers:Array
_callbacks | property |
protected var _callbacks:Array
_data | property |
protected var _data:Array
_flashPoint | property |
protected var _flashPoint:Point
Rendering helper.
_flashRect | property |
protected var _flashRect:Rectangle
_rects | property |
protected var _rects:Array
_tileHeight | property |
protected var _tileHeight:uint
_tileObjects | property |
protected var _tileObjects:Array
_tiles | property |
protected var _tiles:BitmapData
_tileWidth | property |
protected var _tileWidth:uint
auto | property |
public var auto:uint
Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).
cameras | property |
public var cameras:Array
collideIndex | property |
public var collideIndex:uint
What tile index will you start colliding with (default: 1).
drawIndex | property |
public var drawIndex:uint
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().
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
startingIndex | property |
public var startingIndex:uint
The first index of your tile sheet (default: 0) If you want to change it, do so before calling loadMap().
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 — An embedded graphic, preferably black and white.
| |
Invert:Boolean (default = false ) — Load white pixels as solid instead.
| |
Scale:uint (default = 1 ) — 1 pixel = Scale number of tiles. Default is 1.
|
String — A comma-separated string containing the level data in a FlxTilemap -friendly format.
|
destroy | () | method |
override public function destroy():void
draw | () | method |
override public function draw():void
Draws the tilemap.
drawTilemap | () | method |
protected function drawTilemap(Buffer:FlxTilemapBuffer, Camera:FlxCamera):void
Internal function that actually renders the tilemap to the tilemap buffer. Called by render().
Parameters
Buffer:FlxTilemapBuffer | |
Camera:FlxCamera |
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 )
|
getData | () | method |
public function getData(Simple:Boolean = false):Array
Parameters
Simple:Boolean (default = false )
|
Array |
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.
|
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 )
|
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):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.
|
FlxTilemap — A pointer this instance of FlxTilemap, for chaining as usual :)
|
overlaps | () | method |
override public function overlaps(Object:FlxObject):Boolean
Checks for overlaps between the provided object and any tiles above the collision index.
Parameters
Object:FlxObject — The FlxRect you want to check against.
|
Boolean |
overlapsPoint | () | method |
override public function overlapsPoint(X:Number, Y:Number, Camera:FlxCamera = null, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps a solid tile.
Parameters
X:Number — The X coordinate of the point.
| |
Y:Number — The Y coordinate of the point.
| |
Camera:FlxCamera (default = null ) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
| |
PerPixel:Boolean (default = false ) — Not available in FlxTilemap , ignored.
|
Boolean — Whether or not the point overlaps this object.
|
overlapsWithCallback | () | method |
public function overlapsWithCallback(Object:FlxObject, Callback:Function = null):Boolean
Parameters
Object:FlxObject | |
Callback:Function (default = null )
|
Boolean |
ray | () | method |
public function ray(StartX:Number, StartY:Number, EndX:Number, EndY:Number, Result:FlxPoint, Resolution:Number = 1):Boolean
Shoots a ray from the start point to the end point. If/when it passes through a tile, it stores and returns that point.
Parameters
StartX:Number — The X component of the ray's start.
| |
StartY:Number — The Y component of the ray's start.
| |
EndX:Number — The X component of the ray's end.
| |
EndY:Number — The Y component of the ray's end.
| |
Result:FlxPoint — 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 — Whether or not there was a collision between the ray and a colliding tile.
|
setDirty | () | method |
public function setDirty(Dirty:Boolean = true):void
Parameters
Dirty:Boolean (default = true )
|
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, 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 overlapWithCallback().
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(Object:FlxObject) .
| |
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.
|
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.
|
ALT | Constant |
public static const ALT:uint = 2
Top-down auto-tiling.
AUTO | Constant |
public static const AUTO:uint = 1
Platformer-friendly auto-tiling.
OFF | Constant |
public static const OFF:uint = 0
No auto-tiling.