Packagenet.flashpunk.masks
Classpublic class Grid
InheritanceGrid Inheritance Hitbox Inheritance Mask Inheritance Object

Uses a hash grid to determine collision, faster than using hundreds of Entities for tiled levels, etc.



Public Properties
 PropertyDefined By
  columns : uint
[read-only] How many columns the grid has
Grid
  data : BitmapData
[read-only] The grid data.
Grid
 Inheritedheight : int
Height.
Hitbox
 Inheritedlist : Masklist
The parent Masklist of the mask.
Mask
 Inheritedparent : Entity
The parent Entity of this mask.
Mask
  rows : uint
[read-only] How many rows the grid has.
Grid
  tileHeight : uint
[read-only] The tile height.
Grid
  tileWidth : uint
[read-only] The tile width.
Grid
  usePositions : Boolean
If x/y positions should be used instead of columns/rows.
Grid
 Inheritedwidth : int
Width.
Hitbox
 Inheritedx : int
X offset.
Hitbox
 Inheritedy : int
Y offset.
Hitbox
Public Methods
 MethodDefined By
  
Grid(width:uint, height:uint, tileWidth:uint, tileHeight:uint, x:int = 0, y:int = 0)
Constructor.
Grid
  
clearRect(column:uint = 0, row:uint = 0, width:int = 1, height:int = 1):void
Makes the rectangular region of tiles non-solid.
Grid
  
clearTile(column:uint = 0, row:uint = 0):void
Makes the tile non-solid.
Grid
 Inherited
collide(mask:Mask):Boolean
Checks for collision with another Mask.
Mask
  
getTile(column:uint = 0, row:uint = 0):Boolean
Gets the value of a tile.
Grid
  
loadFromString(str:String, columnSep:String = ,, rowSep:String = ):void
Loads the grid data from a string.
Grid
  
renderDebug(g:Graphics):void
[override]
Grid
  
saveToString(columnSep:String = ,, rowSep:String = ):String
Saves the grid data to a string.
Grid
  
setRect(column:uint = 0, row:uint = 0, width:int = 1, height:int = 1, solid:Boolean = true):void
Sets the value of a rectangle region of tiles.
Grid
  
setTile(column:uint = 0, row:uint = 0, solid:Boolean = true):void
Sets the value of the tile.
Grid
 Inherited
update():void
[override]
Hitbox
Property Detail
columnsproperty
columns:uint  [read-only]

How many columns the grid has


Implementation
    public function get columns():uint
dataproperty 
data:BitmapData  [read-only]

The grid data.


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

How many rows the grid has.


Implementation
    public function get rows():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
Grid()Constructor
public function Grid(width:uint, height:uint, tileWidth:uint, tileHeight:uint, x:int = 0, y:int = 0)

Constructor.

Parameters
width:uint — Width of the grid, in pixels.
 
height:uint — Height of the grid, in pixels.
 
tileWidth:uint — Width of a grid tile, in pixels.
 
tileHeight:uint — Height of a grid tile, in pixels.
 
x:int (default = 0) — X offset of the grid.
 
y:int (default = 0) — Y offset of the grid.
Method Detail
clearRect()method
public function clearRect(column:uint = 0, row:uint = 0, width:int = 1, height:int = 1):void

Makes the rectangular region of tiles non-solid.

Parameters

column:uint (default = 0) — First column.
 
row:uint (default = 0) — First row.
 
width:int (default = 1) — Columns to fill.
 
height:int (default = 1) — Rows to fill.

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

Makes the tile non-solid.

Parameters

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

getTile()method 
public function getTile(column:uint = 0, row:uint = 0):Boolean

Gets the value of a tile.

Parameters

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

Returns
Boolean — tile value.
loadFromString()method 
public function loadFromString(str:String, columnSep:String = ,, rowSep:String = ):void

Loads the grid data from a string.

Parameters

str:String — The string data, which is a set of tile values (0 or 1) 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".

renderDebug()method 
override public function renderDebug(g:Graphics):void

Parameters

g:Graphics

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

Saves the grid 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 = 0, row:uint = 0, width:int = 1, height:int = 1, solid:Boolean = true):void

Sets the value of a rectangle region of tiles.

Parameters

column:uint (default = 0) — First column.
 
row:uint (default = 0) — First row.
 
width:int (default = 1) — Columns to fill.
 
height:int (default = 1) — Rows to fill.
 
solid:Boolean (default = true) — If the tiles should be solid.

setTile()method 
public function setTile(column:uint = 0, row:uint = 0, solid:Boolean = true):void

Sets the value of the tile.

Parameters

column:uint (default = 0) — Tile column.
 
row:uint (default = 0) — Tile row.
 
solid:Boolean (default = true) — If the tile should be solid.