Packagenet.flashpunk.graphics
Classpublic class Tilemap
InheritanceTilemap Inheritance Canvas Inheritance Graphic Inheritance Object

A canvas to which Tiles can be drawn for fast multiple tile rendering.



Public Properties
 PropertyDefined By
 Inheritedactive : Boolean = false
If the graphic should update.
Graphic
 Inheritedalpha : Number
Change the opacity of the Canvas, a value from 0 to 1.
Canvas
 Inheritedblend : String
Optional blend mode to use (see flash.display.BlendMode for blending modes).
Canvas
 Inheritedcolor : uint
The tinted color of the Canvas.
Canvas
  columns : uint
[read-only] How many columns the tilemap has.
Tilemap
 Inheritedheight : uint
[read-only] Height of the canvas.
Canvas
 Inheritedrelative : Boolean = true
If the graphic should render at its position relative to its parent Entity's position.
Graphic
  rows : uint
[read-only] How many rows the tilemap has.
Tilemap
 InheritedscrollX : Number = 1
X scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
 InheritedscrollY : Number = 1
Y scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
  tileCount : uint
[read-only] How many tiles the tilemap has.
Tilemap
  tileHeight : uint
[read-only] The tile height.
Tilemap
  tileWidth : uint
[read-only] The tile width.
Tilemap
  usePositions : Boolean
If x/y positions should be used instead of columns/rows.
Tilemap
 Inheritedvisible : Boolean = true
If the graphic should render.
Graphic
 Inheritedwidth : uint
[read-only] Width of the canvas.
Canvas
 Inheritedx : Number = 0
X offset.
Graphic
 Inheritedy : Number = 0
Y offset.
Graphic
Protected Properties
 PropertyDefined By
 Inheritedassign : Function
Graphic
 Inherited_rect : Rectangle
Canvas
Public Methods
 MethodDefined By
  
Tilemap(tileset:*, width:uint, height:uint, tileWidth:uint, tileHeight:uint)
Constructor.
Tilemap
 Inherited
applyFilter(filter:BitmapFilter):void
Canvas
  
clearRect(column:uint, row:uint, width:uint = 1, height:uint = 1):void
Clears the rectangular region of tiles.
Tilemap
  
clearTile(column:uint, row:uint):void
Clears the tile at the position.
Tilemap
 Inherited
copyPixels(source:BitmapData, rect:Rectangle, destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null, mergeAlpha:Boolean = false):void
Mimics BitmapData's copyPixels method.
Canvas
  
createGrid(solidTiles:Array, gridInput:* = null):Grid
Create or initialise a Grid object from this tilemap.
Tilemap
 Inherited
draw(x:int, y:int, source:BitmapData, rect:Rectangle = null):void
Draws to the canvas.
Canvas
 Inherited
drawGraphic(x:int, y:int, source:Graphic):void
Draws the Graphic object to the canvas.
Canvas
 Inherited
drawRect(rect:Rectangle, color:uint = 0, alpha:Number = 1):void
Draws over a rectangular area of the canvas.
Canvas
 Inherited
fill(rect:Rectangle, color:uint = 0, alpha:Number = 1):void
Fills the rectangular area of the canvas.
Canvas
 Inherited
fillTexture(rect:Rectangle, texture:BitmapData):void
Fills the rectangle area of the canvas with the texture.
Canvas
  
floodFill(column:uint, row:uint, index:uint = 0):void
Makes a flood fill on the tilemap
Tilemap
  
getIndex(tilesColumn:uint, tilesRow:uint):uint
Gets the 1D index of a tile from a 2D index (its column and row in the tileset image).
Tilemap
 Inherited
getPixel(x:int, y:int):uint
Canvas
  
getSubMap(x:int, y:int, w:int, h:int):Tilemap
Get a subregion of the tilemap and return it as a new Tilemap.
Tilemap
  
getTile(column:uint, row:uint):uint
Gets the tile index at the position.
Tilemap
  
line(x1:int, y1:int, x2:int, y2:int, id:int):void
Draws a line of tiles
Tilemap
  
loadFromString(str:String, columnSep:String = ,, rowSep:String = ):void
Loads the Tilemap tile index data from a string.
Tilemap
 Inherited
render(target:BitmapData, point:Point, camera:Point):void
Renders the graphic to the screen buffer.
Graphic
  
saveToString(columnSep:String = ,, rowSep:String = ):String
Saves the Tilemap tile index data to a string.
Tilemap
 Inherited
setPixel(x:int, y:int, color:uint):void
Canvas
  
setRect(column:uint, row:uint, width:uint = 1, height:uint = 1, index:uint = 0):void
Sets a rectangular region of tiles to the index.
Tilemap
  
setRectOutline(x:int, y:int, width:int, height:int, id:int):void
Draws an outline of a rectangle of tiles
Tilemap
  
setTile(column:uint, row:uint, index:uint = 0):void
Sets the index of the tile at the position.
Tilemap
 Inherited
shift(x:int = 0, y:int = 0):void
Shifts the canvas' pixels by the offset.
Canvas
  
shiftTiles(columns:int, rows:int, wrap:Boolean = false):void
Shifts all the tiles in the tilemap.
Tilemap
 Inherited
update():void
Updates the graphic.
Graphic
  
updateAll():void
Updates the graphical cache for the whole tilemap.
Tilemap
  
updateRect(rect:Rectangle, clear:Boolean):void
Updates the graphical cache of a region of the tilemap.
Tilemap
Property Detail
columnsproperty
columns:uint  [read-only]

How many columns the tilemap has.


Implementation
    public function get columns():uint
rowsproperty 
rows:uint  [read-only]

How many rows the tilemap has.


Implementation
    public function get rows():uint
tileCountproperty 
tileCount:uint  [read-only]

How many tiles the tilemap has.


Implementation
    public function get tileCount():uint
tileHeightproperty 
tileHeight:uint  [read-only]

The tile height.


Implementation
    public function get tileHeight():uint
tileWidthproperty 
tileWidth:uint  [read-only]

The tile width.


Implementation
    public function get tileWidth():uint
usePositionsproperty 
public var usePositions:Boolean

If x/y positions should be used instead of columns/rows.

Constructor Detail
Tilemap()Constructor
public function Tilemap(tileset:*, width:uint, height:uint, tileWidth:uint, tileHeight:uint)

Constructor.

Parameters
tileset:* — The source tileset image.
 
width:uint — Width of the tilemap, in pixels.
 
height:uint — Height of the tilemap, in pixels.
 
tileWidth:uint — Tile width.
 
tileHeight:uint — Tile height.
Method Detail
clearRect()method
public function clearRect(column:uint, row:uint, width:uint = 1, height:uint = 1):void

Clears the rectangular region of tiles.

Parameters

column:uint — First tile column.
 
row:uint — First tile row.
 
width:uint (default = 1) — Width in tiles.
 
height:uint (default = 1) — Height in tiles.

clearTile()method 
public function clearTile(column:uint, row:uint):void

Clears the tile at the position.

Parameters

column:uint — Tile column.
 
row:uint — Tile row.

createGrid()method 
public function createGrid(solidTiles:Array, gridInput:* = null):Grid

Create or initialise a Grid object from this tilemap.

Parameters

solidTiles:Array — Array of tile indexes that should be solid.
 
gridInput:* (default = null) — Grid object to populate.

Returns
Grid — Grid
floodFill()method 
public function floodFill(column:uint, row:uint, index:uint = 0):void

Makes a flood fill on the tilemap

Parameters

column:uint — Column to place the flood fill
 
row:uint — Row to place the flood fill
 
index:uint (default = 0) — Tile index.

getIndex()method 
public function getIndex(tilesColumn:uint, tilesRow:uint):uint

Gets the 1D index of a tile from a 2D index (its column and row in the tileset image).

Parameters

tilesColumn:uint — Tileset column.
 
tilesRow:uint — Tileset row.

Returns
uint — Index of the tile.
getSubMap()method 
public function getSubMap(x:int, y:int, w:int, h:int):Tilemap

Get a subregion of the tilemap and return it as a new Tilemap.

Parameters

x:int
 
y:int
 
w:int
 
h:int

Returns
Tilemap
getTile()method 
public function getTile(column:uint, row:uint):uint

Gets the tile index at the position.

Parameters

column:uint — Tile column.
 
row:uint — Tile row.

Returns
uint — The tile index.
line()method 
public function line(x1:int, y1:int, x2:int, y2:int, id:int):void

Draws a line of tiles

Parameters

x1:int — The x coordinate to start
 
y1:int — The y coordinate to start
 
x2:int — The x coordinate to end
 
y2:int — The y coordinate to end
 
id:int — The tiles id to draw

loadFromString()method 
public function loadFromString(str:String, columnSep:String = ,, rowSep:String = ):void

Loads the Tilemap tile index data from a string.

Parameters

str:String — The string data, which is a set of tile values separated by the columnSep and rowSep strings.
 
columnSep:String (default = ,) — The string that separates each tile value on a row, default is ",".
 
rowSep:String (default = ) — The string that separates each row of tiles, default is "\n".

saveToString()method 
public function saveToString(columnSep:String = ,, rowSep:String = ):String

Saves the Tilemap tile index data to a string.

Parameters

columnSep:String (default = ,) — The string that separates each tile value on a row, default is ",".
 
rowSep:String (default = ) — The string that separates each row of tiles, default is "\n".

Returns
String
setRect()method 
public function setRect(column:uint, row:uint, width:uint = 1, height:uint = 1, index:uint = 0):void

Sets a rectangular region of tiles to the index.

Parameters

column:uint — First tile column.
 
row:uint — First tile row.
 
width:uint (default = 1) — Width in tiles.
 
height:uint (default = 1) — Height in tiles.
 
index:uint (default = 0) — Tile index.

setRectOutline()method 
public function setRectOutline(x:int, y:int, width:int, height:int, id:int):void

Draws an outline of a rectangle of tiles

Parameters

x:int — The x coordinate of the rectangle
 
y:int — The y coordinate of the rectangle
 
width:int — The width of the rectangle
 
height:int — The height of the rectangle
 
id:int — The tiles id to draw

setTile()method 
public function setTile(column:uint, row:uint, index:uint = 0):void

Sets the index of the tile at the position.

Parameters

column:uint — Tile column.
 
row:uint — Tile row.
 
index:uint (default = 0) — Tile index.

shiftTiles()method 
public function shiftTiles(columns:int, rows:int, wrap:Boolean = false):void

Shifts all the tiles in the tilemap.

Parameters

columns:int — Horizontal shift.
 
rows:int — Vertical shift.
 
wrap:Boolean (default = false) — If tiles shifted off the canvas should wrap around to the other side.

updateAll()method 
public function updateAll():void

Updates the graphical cache for the whole tilemap.

updateRect()method 
public function updateRect(rect:Rectangle, clear:Boolean):void

Updates the graphical cache of a region of the tilemap.

Parameters

rect:Rectangle
 
clear:Boolean