Moai SDK  1.5 revision 1 (MoaiEdition)
MOAIGridSpace Class Reference
Inheritance diagram for MOAIGridSpace:
MOAIGrid MOAITileDeck2D

List of all members.

Function List

  cellAddrToCoord
  getCellAddr
  getCellSize
  getOffset
  getSize
  getTileLoc
  getTileSize
  initDiamondGrid
  initHexGrid
  initObliqueGrid
  initRectGrid
  locToCellAddr
  locToCoord
  setRepeat
  setShape
  setSize
  wrapCoord

Function Documentation

Returns the coordinate of a cell given an address.


function cellAddrToCoord ( MOAIGridSpace self, number cellAddr )
Parameters:
self ( MOAIGridSpace )
cellAddr ( number )
Returns:
xTile ( number ), yTile ( number )

Returns the address of a cell given a coordinate (in tiles).


function getCellAddr ( MOAIGridSpace self, number xTile, number yTile )
Parameters:
self ( MOAIGridSpace )
xTile ( number )
yTile ( number )
Returns:
cellAddr ( number )

Returns the dimensions of a single grid cell.


function getCellSize ( MOAIGridSpace self )
Parameters:
self ( MOAIGridSpace )
Returns:
width ( number ), height ( number )

Returns the offset of tiles from cells.


function getOffset ( MOAIGridSpace self )
Parameters:
self ( MOAIGridSpace )
Returns:
xOff ( number ), yOff ( number )

Returns the dimensions of the grid (in tiles).


function getSize ( MOAIGridSpace self )
Parameters:
self ( MOAIGridSpace )
Returns:
width ( number ), height ( number )

Returns the grid space coordinate of the tile. The optional 'position' flag determines the location of the coordinate within the tile.


function getTileLoc ( MOAIGridSpace self, number xTile, number yTile [, number position ] )
Parameters:
self ( MOAIGridSpace )
xTile ( number )
yTile ( number )
position ( number ) Optional. See MOAIGridSpace for list of positions. Default it MOAIGridSpace.TILE_CENTER.
Returns:
x ( number ), y ( number )

Returns the dimensions of a single grid tile.


function getTileSize ( MOAIGridSpace self )
Parameters:
self ( MOAIGridSpace )
Returns:
width ( number ), height ( number )

Initialize a grid with hexagonal tiles.


function initDiamondGrid ( MOAIGridSpace self, number width, number height [, number tileWidth, number tileHeight, number xGutter, number yGutter ] )
Parameters:
self ( MOAIGridSpace )
width ( number )
height ( number )
tileWidth ( number ) Optional. Default value is 1.
tileHeight ( number ) Optional. Default value is 1.
xGutter ( number ) Optional. Default value is 0.
yGutter ( number ) Optional. Default value is 0.
Returns:
nil

Initialize a grid with hexagonal tiles.


function initHexGrid ( MOAIGridSpace self, number width, number height [, number radius, number xGutter, number yGutter ] )
Parameters:
self ( MOAIGridSpace )
width ( number )
height ( number )
radius ( number ) Optional. Default value is 1.
xGutter ( number ) Optional. Default value is 0.
yGutter ( number ) Optional. Default value is 0.
Returns:
nil

Initialize a grid with oblique tiles.


function initObliqueGrid ( MOAIGridSpace self, number width, number height [, number tileWidth, number tileHeight, number xGutter, number yGutter ] )
Parameters:
self ( MOAIGridSpace )
width ( number )
height ( number )
tileWidth ( number ) Optional. Default value is 1.
tileHeight ( number ) Optional. Default value is 1.
xGutter ( number ) Optional. Default value is 0.
yGutter ( number ) Optional. Default value is 0.
Returns:
nil

Initialize a grid with rectangular tiles.


function initRectGrid ( MOAIGridSpace self, number width, number height [, number tileWidth, number tileHeight, number xGutter, number yGutter ] )
Parameters:
self ( MOAIGridSpace )
width ( number )
height ( number )
tileWidth ( number ) Optional. Default value is 1.
tileHeight ( number ) Optional. Default value is 1.
xGutter ( number ) Optional. Default value is 0.
yGutter ( number ) Optional. Default value is 0.
Returns:
nil

Returns the address of a cell given a a coordinate in grid space.


function locToCellAddr ( MOAIGridSpace self, number x, number y )
Parameters:
self ( MOAIGridSpace )
x ( number )
y ( number )
Returns:
cellAddr ( number )

Transforms a coordinate in grid space into a tile index.


function locToCoord ( MOAIGridSpace self, number x, number y )
Parameters:
self ( MOAIGridSpace )
x ( number )
y ( number )
Returns:
xTile ( number ), yTile ( number )

Repeats a grid indexer along X or Y. Only used when a grid is attached.


function setRepeat ( MOAIGridSpace self [, boolean repeatX, boolean repeatY ] )
Parameters:
self ( MOAIGridSpace )
repeatX ( boolean ) Optional. Default value is true.
repeatY ( boolean ) Optional. Default value is repeatX.
Returns:
nil

Set the shape of the grid tiles.


function setShape ( MOAIGridSpace self [, number shape ] )
Parameters:
self ( MOAIGridSpace )
shape ( number ) Optional. One of MOAIGridSpace.RECT_SHAPE, MOAIGridSpace.DIAMOND_SHAPE, MOAIGridSpace.OBLIQUE_SHAPE, MOAIGridSpace.HEX_SHAPE. Default value is MOAIGridSpace.RECT_SHAPE.
Returns:
nil

Initializes dimensions of grid and reserves storage for tiles.


function setSize ( MOAIGridSpace self, number width, number height [, number cellWidth, number cellHeight, number xOff, number yOff, number tileWidth, number tileHeight ] )
Parameters:
self ( MOAIGridSpace )
width ( number )
height ( number )
cellWidth ( number ) Optional. Default value is 1.
cellHeight ( number ) Optional. Default value is 1.
xOff ( number ) Optional. X offset of the tile from the cell.
yOff ( number ) Optional. Y offset of the tile from the cell.
tileWidth ( number ) Optional. Default value is cellWidth.
tileHeight ( number ) Optional. Default value is cellHeight.
Returns:
nil

Reimplemented in MOAITileDeck2D.

Wraps a tile index to the range of the grid.


function wrapCoord ( MOAIGridSpace self, number xTile, number yTile )
Parameters:
self ( MOAIGridSpace )
xTile ( number )
yTile ( number )
Returns:
xTile ( number ), yTile ( number )