Renderable2DGrid
Extends:
Renderable2DGrid is a renderable component which uses two textures to draw tilemaps using the GPU, and just one renderable. Renderable2DGrid will expect one texture for sprites, and another containing the data for which tile goes where. Additionaly, viewport support is added to make large maps require one time loads into self managed data textures.
Constructor Summary
Public Constructor | ||
public |
constructor(mapTilesTextureName: string, gridData: Array, width: number, height: number, tileViewWidth: number, tileViewHeight: number) Constructor for Renderable2D grid. |
Member Summary
Public Members | ||
public |
|
|
public |
dataArray: * |
|
public |
|
|
public |
|
|
public |
shaderTileData: *[] |
Method Summary
Public Methods | ||
public |
buildShaderTileData(viewportX1: number, viewportY1: number, viewportWidth: number, viewportHeight: number) Sets the viewport of the map grid to x1, y1, width, height (in tiles). |
|
public |
onEnd() |
|
public |
setGridData(data: *, width: *, height: *, tileViewWidth: *, tileViewHeight: *) |
|
public |
setUniformData(positionMatrix: Matrix3): boolean Updates the uniforms of this renderable. |
|
public |
updateDataArray(data: *, x1: *, y1: *, width: *, height: *) |
|
public |
Updates the data texture by quadrant. |
|
public |
updateGridDataViewport(data: *, x1: *, y1: *, width: *, height: *) |
Inherited Summary
From class Updateable | ||
public |
deregister: * |
|
public |
|
|
public |
|
|
public |
id: * |
|
public |
Cleanup code for when destroying an Updateable. |
|
public |
end() Base call function for when this Updateable is to be ended. |
|
public |
onEnd() Called when the object is being removed or cleaned up from usage. |
|
public |
onPause() Called when the object is intended to be paused. |
|
public |
onStart() Called when the the object is first introduced. |
|
public |
Called when the object is to be unpaused from paused state. |
|
public |
onUpdate() Called on every update within the game, once the object has had onStart called. |
|
public |
pause() Base call function for when this Updateable is to be paused. |
|
public |
start() Base call function for when this Updateable is to be started. |
|
public |
unpause() Base call function for when this Updateable is to be unpaused. |
|
public |
update() Base call function for when this Updateable is to be updated. |
From class Component | ||
public |
|
|
public |
isUnique: * |
|
public |
Called when the component is successfully added to a GameObject. |
From class Renderable | ||
public |
color: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
program: * |
|
public |
|
|
public |
textures: *[] |
|
private |
|
|
private |
|
|
private |
|
|
private |
_matrixScale: * |
|
private |
|
|
public |
addToViewport(viewportID: number): * Adds this component to another viewport to be drawn. |
|
public |
getMatrix(): * Returns a joined matrix of position, scale, rotation and origin adjustment. |
|
public |
Called immediatly after the Render component is added to a game object. |
|
public |
onEnd() |
|
public |
Removes the renderable from all viewports. |
|
public |
|
|
public |
setColor(r: *, g: *, b: *, a: *) |
|
public |
setDepth(depth: *) |
|
public |
setOriginOffset(point: Point) Sets the origin offset matrix to the new position point assigned. |
|
public |
setPosition(point: Point) Sets the position matrix to the new position point assigned. |
|
public |
setRotation(rotation: number) Sets the rotation matrix to the new rotation value assigned. |
|
public |
Sets the scale matrix to the new scale point assigned. |
|
public |
setSubIndex(spriteIndex: *) |
|
public |
setTexture(textureObject: *) |
|
public |
setUniformData(positionMatrix: *): boolean |
From class Renderable2DMultitex | ||
public |
|
|
public |
textures: *[] |
|
public |
addTexture(textureObject: textureJSONObject) Adds a texture to this renderable. |
|
public |
removeTexture(textureIndex: number) Removes the nth texture from this component. |
|
public |
Removes all textures from this renderable. |
Public Constructors
public constructor(mapTilesTextureName: string, gridData: Array, width: number, height: number, tileViewWidth: number, tileViewHeight: number) source
Constructor for Renderable2D grid. Sets up data and initializes a data texture.
Override:
Renderable2DMultitex#constructorParams:
Name | Type | Attribute | Description |
mapTilesTextureName | string | Name of sprite sheet texture. |
|
gridData | Array | Array of indexes for each tile on the map. |
|
width | number | Width of the map. |
|
height | number | Height of the map. |
|
tileViewWidth | number | Width of the viewport. |
|
tileViewHeight | number | Height of the viewport. |
Public Members
public dataArray: * source
public mapTilesDataTextureName: * source
public mapTilesTexture: * source
public shaderTileData: *[] source
Public Methods
public buildShaderTileData(viewportX1: number, viewportY1: number, viewportWidth: number, viewportHeight: number) source
Sets the viewport of the map grid to x1, y1, width, height (in tiles).
public onEnd() source
Called when the object is being removed or cleaned up from usage.
Override:
Renderable#onEndpublic setGridData(data: *, width: *, height: *, tileViewWidth: *, tileViewHeight: *) source
Params:
Name | Type | Attribute | Description |
data | * | ||
width | * | ||
height | * | ||
tileViewWidth | * | ||
tileViewHeight | * |
public setUniformData(positionMatrix: Matrix3): boolean source
Updates the uniforms of this renderable. Requires a position matrix for perspective calculations by the RendererManager.
Override:
Renderable#setUniformDataParams:
Name | Type | Attribute | Description |
positionMatrix | Matrix3 | Position matrix of this renderable. |
public updateDataArray(data: *, x1: *, y1: *, width: *, height: *) source
Params:
Name | Type | Attribute | Description |
data | * | ||
x1 | * | ||
y1 | * | ||
width | * | ||
height | * |
public updateGridData(data: Array, x1: number, y1: number, width: number, height: number) source
Updates the data texture by quadrant. Quadrant is specified by the x1, y1, width, and height parameters.
public updateGridDataViewport(data: *, x1: *, y1: *, width: *, height: *) source
Params:
Name | Type | Attribute | Description |
data | * | ||
x1 | * | ||
y1 | * | ||
width | * | ||
height | * |