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
If an object is not alive, the game loop will not automatically call
update() on it. | 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 | ||
![]() | bottom : Number
The Y coordinate of the bottom of the rectangle.
| FlxRect | |
![]() | colHullX : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | |
![]() | colHullY : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | |
![]() | collideBottom : Boolean
Flag for direction collision resolution.
| FlxObject | |
collideIndex : uint
What tile index will you start colliding with (default: 1).
| FlxTilemap | ||
![]() | collideLeft : Boolean
Flag for direction collision resolution.
| FlxObject | |
![]() | collideRight : Boolean
Flag for direction collision resolution.
| FlxObject | |
![]() | collideTop : Boolean
Flag for direction collision resolution.
| FlxObject | |
![]() | colOffsets : Array
An array of
FlxPoint objects. | FlxObject | |
![]() | colVector : FlxPoint
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | |
![]() | dead : Boolean
Handy for tracking gameplay or animations.
| FlxObject | |
![]() | 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 | ||
![]() | exists : Boolean
Kind of a global on/off switch for any objects descended from
FlxObject . | FlxObject | |
![]() | fixed : Boolean
Set
fixed to true if you want the object to stay in place during collisions. | FlxObject | |
![]() | _group : Boolean
Dedicated internal flag for whether or not this class is a FlxGroup.
| FlxObject | |
![]() | health : Number
Handy for storing health percentage or armor points or whatever.
| FlxObject | |
![]() | height : Number | FlxRect | |
heightInTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
| FlxTilemap | ||
ImgAuto : Class [static]
| FlxTilemap | ||
ImgAutoAlt : Class [static]
| FlxTilemap | ||
![]() | left : Number
The X coordinate of the left side of the rectangle.
| FlxRect | |
![]() | maxAngular : Number
Use in conjunction with
angularAcceleration for fluid spin speed control. | FlxObject | |
![]() | maxThrust : Number
Used to cap
thrust , helpful and easy!
| 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 | |
![]() | onFloor : Boolean
Flag that indicates whether or not you just hit the floor.
| FlxObject | |
![]() | origin : FlxPoint
WARNING: The origin of the sprite will default to its center.
| FlxObject | |
refresh : Boolean
Set this flag to true to force the tilemap buffer to refresh on the next render frame.
| FlxTilemap | ||
![]() | right : Number
The X coordinate of the right side of the rectangle.
| FlxRect | |
![]() | 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
Set
solid to true if you want to collide this object. | FlxObject | |
startingIndex : uint
The first index of your tile sheet (default: 0) If you want to change it, do so before calling loadMap().
| FlxTilemap | ||
![]() | thrust : Number
If you want to do Asteroids style stuff, check out thrust,
instead of directly accessing the object's velocity or acceleration.
| FlxObject | |
![]() | top : Number
The Y coordinate of the top of the rectangle.
| FlxRect | |
totalTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
| FlxTilemap | ||
![]() | velocity : FlxPoint
The basic speed of this object.
| FlxObject | |
![]() | visible : Boolean
If an object is not visible, the game loop will not automatically call
render() on it. | FlxObject | |
![]() | width : Number | FlxRect | |
widthInTiles : uint
Read-only variable, do NOT recommend changing after the map is loaded!
| FlxTilemap | ||
![]() | x : Number | FlxPoint | |
![]() | y : Number | FlxPoint |
Property | Defined by | ||
---|---|---|---|
_bbKey : String | FlxTilemap | ||
_bbPixels : BitmapData | FlxTilemap | ||
_block : FlxObject | FlxTilemap | ||
_boundsVisible : Boolean | FlxTilemap | ||
_buffer : BitmapData | FlxTilemap | ||
_bufferLoc : FlxPoint | FlxTilemap | ||
_callbacks : Array | FlxTilemap | ||
_data : Array | FlxTilemap | ||
![]() | _fixed : Boolean
Internal tracker for whether an object will move/alter position after a collision (see
fixed ). | FlxObject | |
![]() | _flashPoint : Point
This is a pre-allocated Flash Point object, which is useful for certain Flash graphics API calls
| FlxObject | |
_flashRect : Rectangle
Rendering helper.
| FlxTilemap | ||
_flashRect2 : Rectangle | FlxTilemap | ||
![]() | _flicker : Boolean
Internal helper used for retro-style flickering.
| FlxObject | |
![]() | _flickerTimer : Number
Internal helper used for retro-style flickering.
| FlxObject | |
_pixels : BitmapData | FlxTilemap | ||
![]() | _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 | ||
_screenCols : uint | FlxTilemap | ||
_screenRows : uint | FlxTilemap | ||
![]() | _solid : Boolean
Internal tracker for whether or not the object collides (see
solid ). | FlxObject | |
_tileHeight : uint | FlxTilemap | ||
_tileWidth : uint | FlxTilemap |
Method | Defined by | ||
---|---|---|---|
The tilemap constructor just initializes some basic variables.
| FlxTilemap | ||
arrayToCSV(Data:Array, Width:int):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 | ||
![]() |
If you don't want to call
FlxU.collide() you can use this instead. | FlxObject | |
![]() |
destroy():void
Called by
FlxGroup , commonly when game states are changed. | FlxObject | |
![]() |
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
| FlxObject | |
![]() |
flickering():Boolean
Check to see if the object is still flickering.
| FlxObject | |
follow(Border:int = 0):void
Call this function to lock the automatic camera to the map's edges.
| FlxTilemap | ||
![]() |
getBoundingColor():uint
Returns the appropriate color for the bounding box depending on object state.
| 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 | ||
![]() |
Called when this object's bottom edge collides with the top of another
FlxObject . | FlxObject | |
![]() |
Called when this object's left side collides with another
FlxObject 's right. | FlxObject | |
![]() |
Called when this object's right side collides with another
FlxObject 's left. | FlxObject | |
![]() |
Since most games have identical behavior for running into walls,
you can just override this function instead of overriding both hitLeft and hitRight.
| FlxObject | |
![]() |
Called when this object's top collides with the bottom of another
FlxObject . | FlxObject | |
![]() |
hurt(Damage:Number):void
Call this function to "damage" (or give health bonus) to this sprite.
| FlxObject | |
imageToCSV(ImageFile:Class, Invert:Boolean = false, Scale:uint = 1):String
[static]
Converts a resource image file to a comma-separated string.
| FlxTilemap | ||
![]() |
kill():void
Call this function to "kill" a sprite so that it no longer 'exists'.
| FlxObject | |
loadMap(MapData:String, TileGraphic:Class, TileWidth:uint = 0, TileHeight:uint = 0):FlxTilemap
Load the tilemap with string data and a tile graphic.
| FlxTilemap | ||
![]() |
onScreen():Boolean
Check and see if this object is currently on screen.
| FlxObject | |
Checks for overlaps between the provided object and any tiles above the collision index.
| FlxTilemap | ||
overlapsPoint(X:Number, Y:Number, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps a solid tile.
| FlxTilemap | ||
preCollide(Object:FlxObject):void
FlxU.collide() (and thus FlxObject.collide() ) call
this function each time two objects are compared to see if they collide. | FlxTilemap | ||
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 | ||
refreshHulls():void
Called by
FlxObject.updateMotion() and some constructors to
rebuild the basic collision data for this object. | FlxTilemap | ||
render():void
Draws the tilemap.
| FlxTilemap | ||
![]() |
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
| FlxObject | |
setCallback(Tile:uint, Callback:Function, Range:uint = 1):void
Bind a function Callback(Core:FlxCore,X:uint,Y:uint,Tile:uint) to a range of tiles.
| 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 | ||
![]() |
toString():String
Convert object to readable string name.
| FlxPoint | |
update():void
Checks to see if the tilemap needs to be refreshed or not.
| FlxTilemap |
Method | Defined by | ||
---|---|---|---|
autoTile(Index:uint):void
An internal function used by the binary auto-tilers.
| FlxTilemap | ||
generateBoundingTiles():void
Generates a bounding box version of the tiles, flixel should call this automatically when necessary.
| FlxTilemap | ||
renderTilemap():void
Internal function that actually renders the tilemap to the tilemap buffer.
| FlxTilemap | ||
![]() |
updateFlickering():void
Just updates the retro-style flickering.
| FlxObject | |
![]() |
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 | ||
AUTO : uint = 1 [static]
Platformer-friendly auto-tiling.
| FlxTilemap | ||
OFF : uint = 0 [static]
No auto-tiling.
| FlxTilemap |
auto | property |
public var auto:uint
Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).
_bbKey | property |
protected var _bbKey:String
_bbPixels | property |
protected var _bbPixels:BitmapData
_block | property |
protected var _block:FlxObject
_boundsVisible | property |
protected var _boundsVisible:Boolean
_buffer | property |
protected var _buffer:BitmapData
_bufferLoc | property |
protected var _bufferLoc:FlxPoint
_callbacks | property |
protected var _callbacks:Array
collideIndex | property |
public var collideIndex:uint
What tile index will you start colliding with (default: 1).
_data | property |
protected var _data:Array
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().
_flashRect | property |
protected var _flashRect:Rectangle
Rendering helper.
_flashRect2 | property |
protected var _flashRect2:Rectangle
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
_pixels | property |
protected var _pixels:BitmapData
_rects | property |
protected var _rects:Array
refresh | property |
public var refresh:Boolean
Set this flag to true to force the tilemap buffer to refresh on the next render frame.
_screenCols | property |
protected var _screenCols:uint
_screenRows | property |
protected var _screenRows:uint
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().
_tileHeight | property |
protected var _tileHeight:uint
_tileWidth | property |
protected var _tileWidth:uint
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):String
Converts a one-dimensional array of tile data to a comma-separated string.
ParametersData:Array — An array full of integer tile references.
|
|
Width:int — The number of tiles in each row.
|
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.
ParametersIndex: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.
bitmapData:BitmapData — 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.
|
follow | () | method |
public function follow(Border:int = 0):void
Call this function to lock the automatic camera to the map's edges.
ParametersBorder: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.
|
generateBoundingTiles | () | method |
protected function generateBoundingTiles():void
Generates a bounding box version of the tiles, flixel should call this automatically when necessary.
getTile | () | method |
public function getTile(X:uint, Y:uint):uint
Check the value of a particular tile.
ParametersX: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.
ParametersIndex: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.
ParametersImageFile: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.
ParametersMapData: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 |
public override function overlaps(Core:FlxObject):Boolean
Checks for overlaps between the provided object and any tiles above the collision index.
ParametersCore:FlxObject — The FlxCore you want to check against.
|
Boolean |
overlapsPoint | () | method |
public override function overlapsPoint(X:Number, Y:Number, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps a solid tile.
ParametersX:Number — The X coordinate of the point.
|
|
Y:Number — The Y coordinate of the point.
|
|
PerPixel:Boolean (default = false ) — Not available in FlxTilemap , ignored.
|
Boolean — Whether or not the point overlaps this object.
|
preCollide | () | method |
public override function preCollide(Object:FlxObject):void
FlxU.collide()
(and thus FlxObject.collide()
) call
this function each time two objects are compared to see if they collide.
It doesn't necessarily mean these objects WILL collide, however.
Object:FlxObject — The FlxObject you're about to run into.
|
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.
ParametersStartX: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.
|
refreshHulls | () | method |
public override function refreshHulls():void
Called by FlxObject.updateMotion()
and some constructors to
rebuild the basic collision data for this object.
render | () | method |
public override function render():void
Draws the tilemap.
renderTilemap | () | method |
protected function renderTilemap():void
Internal function that actually renders the tilemap to the tilemap buffer. Called by render().
setCallback | () | method |
public function setCallback(Tile:uint, Callback:Function, Range:uint = 1):void
Bind a function Callback(Core:FlxCore,X:uint,Y:uint,Tile:uint) to a range of tiles.
ParametersTile:uint — The tile to trigger the callback.
|
|
Callback:Function — The function to trigger. Parameters should be (Core:FlxCore,X:uint,Y:uint,Tile:uint) .
|
|
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.
|
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.
ParametersX: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.
ParametersIndex: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.
|
update | () | method |
public override function update():void
Checks to see if the tilemap needs to be refreshed or not.
updateTile | () | method |
protected function updateTile(Index:uint):void
Internal function used in setTileByIndex() and the constructor to update the map.
ParametersIndex: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.