Graphics.Grid

Description: Defines a drawable grid that can be used to store other graphics in a grid like structure.

Extends: Graphics.Graphic2d

Constructors

Grid (x, y, rows, columns, tileWidth, tileHeight)
Creates a new instance of the Grid object.

x: number
Initial horizontal location of the grid.

y: number
Initial vertical location of the grid.

rows: number
Number of rows the grid will have (this cannot change after construction).

columns: number
Number of columns the grid will have (this cannot change after construction).

tileWidth: number
The width of the grid tiles (this cannot change after construction).

tileHeight: number
The height of the grid tiles (this cannot change after construction).

Grid (x, y, rows, columns, tileWidth, tileHeight, drawGridLines)
Creates a new instance of the Grid object.

x: number
Initial horizontal location of the grid.

y: number
Initial vertical location of the grid.

rows: number
Number of rows the grid will have (this cannot change after construction).

columns: number
Number of columns the grid will have (this cannot change after construction).

tileWidth: number
The width of the grid tiles (this cannot change after construction).

tileHeight: number
The height of the grid tiles (this cannot change after construction).

drawGridLines: boolean
Initial value for DrawGridLines.

Grid (x, y, rows, columns, tileWidth, tileHeight, drawGridLines, gridLineColor)
Creates a new instance of the Grid object.

x: number
Initial horizontal location of the grid.

y: number
Initial vertical location of the grid.

rows: number
Number of rows the grid will have (this cannot change after construction).

columns: number
Number of columns the grid will have (this cannot change after construction).

tileWidth: number
The width of the grid tiles (this cannot change after construction).

tileHeight: number
The height of the grid tiles (this cannot change after construction).

drawGridLines: boolean
Initial value for DrawGridLines.

gridLineColor: Graphics.Color
Initial grid line color (only useful if drawGridLines is true);

Grid (x, y, rows, columns, tileWidth, tileHeight, drawGridLines, gridLineColor)
Creates a new instance of the Grid object.

x: number
Initial horizontal location of the grid.

y: number
Initial vertical location of the grid.

rows: number
Number of rows the grid will have (this cannot change after construction).

columns: number
Number of columns the grid will have (this cannot change after construction).

tileWidth: number
The width of the grid tiles (this cannot change after construction).

tileHeight: number
The height of the grid tiles (this cannot change after construction).

drawGridLines: boolean
Initial value for DrawGridLines.

gridLineColor: string
Initial grid line color (only useful if drawGridLines is true);

Fields

DrawGridLines: boolean
Gets or sets the DrawGridLines property. Indicates whether the grids column and row lines will be drawn.

GridLineColor: Graphics.Color
Gets or sets the current grid line color. Grid lines are only drawn of DrawGridLines is set to true. Valid colors are strings like "red" or "rgb(255,0,0)".

Size: EndGate.Size2d
Gets the size of the grid.

TileSize: EndGate.Size2d
Gets the size of the tiles.

Rows: number
Gets the number of rows.

Columns: number
Gets the number of columns.

Inherited from: Graphics.Graphic2d

ZIndex: number
Gets or sets the ZIndex of the Graphic2d. The ZIndex is used to control draw order. Higher ZIndexes appear above lower ZIndexed graphics.

Visible: boolean
Gets or sets the Visible property. The Visible property determines whether the renderable will be drawn to the game screen.

Position: EndGate.Vector2d
Gets or sets the Position of the Graphic2d. The Position determines where the graphic will be drawn on the screen.

Rotation: number
Gets or sets the Rotation of the Graphic2d..

Parent: Graphic2d
Gets the parent of the Graphic2d. Value is null if no parent exists.

AbsolutePosition: EndGate.Vector2d
Gets the absolute position of the Graphic2d. This is used to calculate absolute positions when graphic's have parents.

OnDisposed: EndGate.EventHandler1 <Graphic2d>
Gets an event that is triggered when the Graphic2d has been disposed. Functions can be bound or unbound to this event to be executed when the event triggers.

Opacity: number
Gets or sets the current opacity. Value is between 0 and 1.

Methods

Fill()
Fills a tile with the provided graphic.

FillRow()
Fills a row with the provided graphics

FillColumn()
Fills a column with the provided graphics

FillSpace()
Fills a tile with the provided graphic.

Get()
Gets a graphic within the grid.

GetRow()
Retrieves graphics within the provided row.

GetColumn()
Retrieves graphics within the provided column.

GetSpace()
Retrieves graphics within row column cross section.

Clear()
Clear a grid tile.

ClearRow()
Clears graphics within the provided row.

ClearColumn()
Clears graphics within the provided column.

ClearSpace()
Clears graphics within row column cross section.

Draw()
Draws the grid onto the given context. If this grid is part of a scene the Draw function will be called automatically.

GetDrawBounds()
The bounding area that represents where the grid will draw.

Scale()
Scale is not implemented.

ConvertToRow()
Converts the provided vertical coordinate to a row number that is based on the current grid.

ConvertToColumn()
Converts the provided horizontal coordinate to a column number that is based on the current grid.

Clone()
Returns a nearly identical copy of this Grid. If this Grid belongs to a parent, the cloned Grid will not. If this Grid has children, all children will be cloned as well. Lastly, the cloned Grid will not have the same event bindings as this one does.

Inherited from: Graphics.Graphic2d

GetChildren()
Returns the list of children for the current Graphic2d.

AddChild()
Adds a child to the Graphic2d. Children are drawn with relative positions to the parent Graphic2d. Children of a Graphic2d should not be added to the Scene, parent Graphic2d's are responsible for drawing their children.

RemoveChild()
Removes a child from the Graphic2d. Returns a Boolean value indicating whether or not the child was able to be removed.

Dispose()
Triggers the OnDisposed event. If this Graphic2d is used with a Scene2d it will be removed from the scene when disposed.

Examples

There's currently no example available for this page. If you'd like to suggest one send me an containing a description, code, and link to the page for the suggested example. As a thanks I'll associate the code snippet with your name directly below the example if approved.