Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2013-9-6 21:36

Class jaws.TileMap

Create and access tilebased 2D maps with very fast access of invidual tiles. "Field Summary" contains options for the TileMap()-constructor.

Class Summary
Constructor Attributes Constructor Name and Description
 
jaws.TileMap(options)
Field Summary
Field Attributes Field Name and Description
 
Size of each cell in tilemap, defaults to [32,32]
 
Size of tilemap, defaults to [100,100]
 
Function used by sortCells() to sort cells, defaults to no sorting

Method Summary

Method Attributes Method Name and Description
 
all()
Returns all objects in tile map
 
at(x, y)
Get objects in cell that exists at coordinates x / y
 
atRect(rect)
Returns occupants of all cells touched by 'rect'
 
cell(col, row)
Get objects in cell at col / row
 
Clear all cells in tile map
 
push(obj)
Push obj (or array of objs) into our cell-grid.
 
Push objects into tilemap.
 
pushAsRect(obj, rect)
push obj into cells touched by rect
 
pushToCell(col, row, obj)
Push obj to a specific cell specified by col and row If cell is already occupied we create an array and push to that
 
sortCells(sortFunction)
Sort arrays in each cell in tile map according to sorter-function (see Array.sort)
 
Debugstring for TileMap()

Class Detail

jaws.TileMap(options)
var tile_map = new TileMap({size: [10, 10], cell_size: [16,16]})
var sprite = new jaws.Sprite({x: 40, y: 40})
var sprite2 = new jaws.Sprite({x: 41, y: 41})
tile_map.push(sprite)

tile_map.at(10,10)  // []
tile_map.at(40,40)  // [sprite]
tile_map.cell(0,0)  // []
tile_map.cell(1,1)  // [sprite]
Parameters:
options

Field Detail

{array} cell_size
Size of each cell in tilemap, defaults to [32,32]
{array} size
Size of tilemap, defaults to [100,100]
{function} sortFunction
Function used by sortCells() to sort cells, defaults to no sorting

Method Detail

  • all()
    Returns all objects in tile map
  • at(x, y)
    Get objects in cell that exists at coordinates x / y
    Parameters:
    x
    y
  • atRect(rect)
    Returns occupants of all cells touched by 'rect'
    Parameters:
    rect
  • cell(col, row)
    Get objects in cell at col / row
    Parameters:
    col
    row
  • clear()
    Clear all cells in tile map
  • push(obj)
    Push obj (or array of objs) into our cell-grid. Tries to read obj.x and obj.y to calculate what cell to occopy
    Parameters:
    obj
  • pushAsPoint(obj)
    Push objects into tilemap. Disregard height and width and only use x/y when calculating cell-position
    Parameters:
    obj
  • pushAsRect(obj, rect)
    push obj into cells touched by rect
    Parameters:
    obj
    rect
  • pushToCell(col, row, obj)
    Push obj to a specific cell specified by col and row If cell is already occupied we create an array and push to that
    Parameters:
    col
    row
    obj
  • sortCells(sortFunction)
    Sort arrays in each cell in tile map according to sorter-function (see Array.sort)
    Parameters:
    sortFunction
  • toString()
    Debugstring for TileMap()