Graphics.SquareTileMap

Description: Defines a structure that is proficient at creating diverse tile maps based off of a resource image. Best drawn via a SceneryHandler.

Extends: Graphics.TileMap

Constructors

SquareTileMap (x, y, tileWidth, tileHeight, resources, mappings)
Creates a new instance of the SquareTileMap object.

x: number
Initial horizontal location of the tile map.

y: number
Initial vertical location of the tile map.

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

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

resources: Graphics.ImageSource[]
A one dimensional array of image resources that make up the tile map (this cannot change after construction).

mappings: number[][]
A two dimensional array numbers that map directly to the resources array to define the square tile map (this cannot change after construction).

SquareTileMap (x, y, tileWidth, tileHeight, resources, mappings, staticMap)
Creates a new instance of the SquareTileMap object.

x: number
Initial horizontal location of the tile map.

y: number
Initial vertical location of the tile map.

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

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

resources: Graphics.ImageSource[]
A one dimensional array of image resources that make up the tile map (this cannot change after construction).

mappings: number[][]
A two dimensional array numbers that map directly to the resources array to define the square tile map (this cannot change after construction).

staticMap: boolean
Whether or not image tiles will change throughout the SquareTileMap's lifetime, defaults to true and cannot change after construction.

SquareTileMap (x, y, tileWidth, tileHeight, resources, mappings, staticMap, drawGridLines)
Creates a new instance of the SquareTileMap object.

x: number
Initial horizontal location of the tile map.

y: number
Initial vertical location of the tile map.

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

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

resources: Graphics.ImageSource[]
A one dimensional array of image resources that make up the tile map (this cannot change after construction).

mappings: number[][]
A two dimensional array numbers that map directly to the resources array to define the square tile map (this cannot change after construction).

staticMap: boolean
Whether or not image tiles will change throughout the SquareTileMap's lifetime, defaults to true and cannot change after construction.

drawGridLines: boolean
Whether or not to draw the tile maps grid lines. Useful when trying to pinpoint specific tiles (this cannot change after construction).

Fields

TileLoadDelay: EndGate.TimeSpan
Gets or sets the tile load delay component. This can be used to slowly load a square tile map to prevent the browser from freezing by adding a delay between tile loads to allow time for the DOM to update. Defaults to TimeSpan.Zero.

RowLoadDelay: EndGate.TimeSpan
Gets or sets the row load delay component. This can be used to slowly load a square tile map to prevent the browser from freezing by adding a delay between row loads to allow time for the DOM to update. Defaults to TimeSpan.Zero.

OnTileLoad: EndGate.EventHandler2 <Graphics.Assets.ITileDetails, number>
Gets an event that is triggered when a tile has been loaded, first argument is the tile details for the loaded tile, second is the percent complete. Once this SquareTileMap has been created and all tiles loaded this event will no longer be triggered. Functions can be bound or unbound to this event to be executed when the event triggers.

OnLoaded: EndGate.EventHandler
Gets an event that is triggered when the square tile map has been loaded. Once this SquareTileMap has been created and all tiles loaded this event will no longer be triggered. Functions can be bound or unbound to this event to be executed when the event triggers.

Inherited from: Graphics.TileMap

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

(Static) ExtractTiles()
Helper function used to take a SpriteSheet image and create a one dimensional resource tile array.

IsLoaded()
Determines if the current SquareTileMap is loaded.

Draw()
Draws the SquareTileMap onto the given context. If the SquareTileMap is part of a Scene2d or SceneryHandler the Draw function will be called automatically.

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

Dispose()
Removes all children and unbinds all events associated with the SquareTileMap.

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

Inherited from: Graphics.TileMap

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.

Scale()
Abstract: Should be overridden to scale the size of the Graphic2d.

Scale()
Scale is not implemented.

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.