Moai SDK  2.0
MOAIGridSpace Class Reference
+ Inheritance diagram for MOAIGridSpace:

Function List

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

Detailed Description

Constants
MOAIGridSpace.TILE_BOTTOM_CENTER
MOAIGridSpace.TILE_CENTER
MOAIGridSpace.TILE_LEFT_BOTTOM
MOAIGridSpace.TILE_LEFT_CENTER
MOAIGridSpace.TILE_LEFT_TOP
MOAIGridSpace.TILE_RIGHT_BOTTOM
MOAIGridSpace.TILE_RIGHT_CENTER
MOAIGridSpace.TILE_RIGHT_TOP
MOAIGridSpace.TILE_TOP_CENTER
MOAIGridSpace.SQUARE_SHAPE
MOAIGridSpace.DIAMOND_SHAPE
MOAIGridSpace.OBLIQUE_SHAPE
MOAIGridSpace.HEX_SHAPE
MOAIGridSpace.AXIAL_HEX_SHAPE
Flags
MOAIGridSpace.TILE_X_FLIP
MOAIGridSpace.TILE_Y_FLIP
MOAIGridSpace.TILE_XY_FLIP
MOAIGridSpace.TILE_HIDE

Function Documentation

cellAddrToCoord

Returns the coordinate of a cell given an address.


function cellAddrToCoord ( MOAIGridSpace self, number cellAddr )

Parameters
MOAIGridSpaceself
numbercellAddr
Returns
number xTile, number yTile
getCellAddr

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


function getCellAddr ( MOAIGridSpace self, number xTile, number yTile )

Parameters
MOAIGridSpaceself
numberxTile
numberyTile
Returns
number cellAddr
getCellSize

Returns the dimensions of a single grid cell.


function getCellSize ( MOAIGridSpace self )

Parameters
MOAIGridSpaceself
Returns
number width, number height
getOffset

Returns the offset of tiles from cells.


function getOffset ( MOAIGridSpace self )

Parameters
MOAIGridSpaceself
Returns
number xOff, number yOff
getSize

Returns the dimensions of the grid (in tiles).


function getSize ( MOAIGridSpace self )

Parameters
MOAIGridSpaceself
Returns
number width, number height
getTileLoc

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
MOAIGridSpaceself
numberxTile
numberyTile
numberposition Optional. See MOAIGridSpace for list of positions. Default it MOAIGridSpace.TILE_CENTER.
Returns
number x, number y
getTileSize

Returns the dimensions of a single grid tile.


function getTileSize ( MOAIGridSpace self )

Parameters
MOAIGridSpaceself
Returns
number width, number height
initAxialHexGrid

Initialize a grid with hex tiles, using an axial coordinate system. The axial grid assumes that the flat sides of hexes are on the sides, and the points are up/down.


function initAxialHexGrid ( MOAIGridSpace self, number width, number height [, number tileWidth, number tileHeight, number xGutter, number yGutter ] )

Parameters
MOAIGridSpaceself
numberwidth
numberheight
numbertileWidth Optional. Default value is 1.
numbertileHeight Optional. Default value is 1.
numberxGutter Optional. Default value is 0.
numberyGutter Optional. Default value is 0.
Returns
nil
initDiamondGrid

Initialize a grid with diamond tiles.


function initDiamondGrid ( MOAIGridSpace self, number width, number height [, number tileWidth, number tileHeight, number xGutter, number yGutter ] )

Parameters
MOAIGridSpaceself
numberwidth
numberheight
numbertileWidth Optional. Default value is 1.
numbertileHeight Optional. Default value is 1.
numberxGutter Optional. Default value is 0.
numberyGutter Optional. Default value is 0.
Returns
nil
initHexGrid

Initialize a grid with hexagonal tiles.


function initHexGrid ( MOAIGridSpace self, number width, number height [, number radius, number xGutter, number yGutter ] )

Parameters
MOAIGridSpaceself
numberwidth
numberheight
numberradius Optional. Default value is 1.
numberxGutter Optional. Default value is 0.
numberyGutter Optional. Default value is 0.
Returns
nil
initObliqueGrid

Initialize a grid with oblique tiles.


function initObliqueGrid ( MOAIGridSpace self, number width, number height [, number tileWidth, number tileHeight, number xGutter, number yGutter ] )

Parameters
MOAIGridSpaceself
numberwidth
numberheight
numbertileWidth Optional. Default value is 1.
numbertileHeight Optional. Default value is 1.
numberxGutter Optional. Default value is 0.
numberyGutter Optional. Default value is 0.
Returns
nil
initRectGrid

Initialize a grid with rectangular tiles.


function initRectGrid ( MOAIGridSpace self, number width, number height [, number tileWidth, number tileHeight, number xGutter, number yGutter ] )

Parameters
MOAIGridSpaceself
numberwidth
numberheight
numbertileWidth Optional. Default value is 1.
numbertileHeight Optional. Default value is 1.
numberxGutter Optional. Default value is 0.
numberyGutter Optional. Default value is 0.
Returns
nil
locToCellAddr

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


function locToCellAddr ( MOAIGridSpace self, number x, number y )

Parameters
MOAIGridSpaceself
numberx
numbery
Returns
number cellAddr
locToCoord

Transforms a coordinate in grid space into a tile index.


function locToCoord ( MOAIGridSpace self, number x, number y )

Parameters
MOAIGridSpaceself
numberx
numbery
Returns
number xTile, number yTile
setRepeat

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


function setRepeat ( MOAIGridSpace self [, boolean repeatX, boolean repeatY ] )

Parameters
MOAIGridSpaceself
booleanrepeatX Optional. Default value is true.
booleanrepeatY Optional. Default value is repeatX.
Returns
nil
setShape

Set the shape of the grid tiles.


function setShape ( MOAIGridSpace self [, number shape ] )

Parameters
MOAIGridSpaceself
numbershape Optional. One of MOAIGridSpace.RECT_SHAPE, MOAIGridSpace.DIAMOND_SHAPE, MOAIGridSpace.OBLIQUE_SHAPE, MOAIGridSpace.HEX_SHAPE, MOAIGridSpace.AXIAL_HEX_SHAPE. Default value is MOAIGridSpace.RECT_SHAPE.
Returns
nil
setSize

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
MOAIGridSpaceself
numberwidth
numberheight
numbercellWidth Optional. Default value is 1.
numbercellHeight Optional. Default value is 1.
numberxOff Optional. X offset of the tile from the cell.
numberyOff Optional. Y offset of the tile from the cell.
numbertileWidth Optional. Default value is cellWidth.
numbertileHeight Optional. Default value is cellHeight.
Returns
nil
wrapCoord

Wraps a tile index to the range of the grid.


function wrapCoord ( MOAIGridSpace self, number xTile, number yTile )

Parameters
MOAIGridSpaceself
numberxTile
numberyTile
Returns
number xTile, number yTile