Package | net.flashpunk.graphics |
Class | public class Tilemap |
Inheritance | Tilemap Canvas Graphic Object |
Property | Defined By | ||
---|---|---|---|
active : Boolean = false
If the graphic should update. | Graphic | ||
alpha : Number
Change the opacity of the Canvas, a value from 0 to 1. | Canvas | ||
blend : String
Optional blend mode to use (see flash.display.BlendMode for blending modes). | Canvas | ||
color : uint
The tinted color of the Canvas. | Canvas | ||
columns : uint [read-only]
How many columns the tilemap has. | Tilemap | ||
height : uint [read-only]
Height of the canvas. | Canvas | ||
relative : 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 | ||
scrollX : Number = 1
X scrollfactor, effects how much the camera offsets the drawn graphic. | Graphic | ||
scrollY : 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 | ||
visible : Boolean = true
If the graphic should render. | Graphic | ||
width : uint [read-only]
Width of the canvas. | Canvas | ||
x : Number = 0
X offset. | Graphic | ||
y : Number = 0
Y offset. | Graphic |
Method | Defined By | ||
---|---|---|---|
Tilemap(tileset:*, width:uint, height:uint, tileWidth:uint, tileHeight:uint)
Constructor. | Tilemap | ||
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 | ||
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 | ||
draw(x:int, y:int, source:BitmapData, rect:Rectangle = null):void
Draws to the canvas. | Canvas | ||
drawGraphic(x:int, y:int, source:Graphic):void
Draws the Graphic object to the canvas. | Canvas | ||
drawRect(rect:Rectangle, color:uint = 0, alpha:Number = 1):void
Draws over a rectangular area of the canvas. | Canvas | ||
fill(rect:Rectangle, color:uint = 0, alpha:Number = 1):void
Fills the rectangular area of the canvas. | Canvas | ||
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 | ||
getPixel(x:int, y:int):uint | Canvas | ||
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 | ||
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 | ||
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 | ||
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 | ||
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 |
columns | property |
columns:uint
[read-only] How many columns the tilemap has.
public function get columns():uint
rows | property |
rows:uint
[read-only] How many rows the tilemap has.
public function get rows():uint
tileCount | property |
tileCount:uint
[read-only] How many tiles the tilemap has.
public function get tileCount():uint
tileHeight | property |
tileHeight:uint
[read-only] The tile height.
public function get tileHeight():uint
tileWidth | property |
tileWidth:uint
[read-only] The tile width.
public function get tileWidth():uint
usePositions | property |
public var usePositions:Boolean
If x/y positions should be used instead of columns/rows.
Tilemap | () | Constructor |
public function Tilemap(tileset:*, width:uint, height:uint, tileWidth:uint, tileHeight:uint)
Constructor.
Parameterstileset:* — 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.
|
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.
|
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.
|
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 |
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.
|
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".
|
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 |