Skip to main content

Grid

Description:

  A class used to render a texture as a grid of sprites, where each sprite can be positioned, colored, and have its UV coordinates manipulated.

Class Object: Grid Class.

Inherits from: Node.

gridX

Type: Readonly Field.

Description:

  The number of columns in the grid. And there are gridX + 1 vertices horizontally for rendering.

Signature:

const gridX: integer

gridY

Type: Readonly Field.

Description:

  The number of rows in the grid. And there are gridY + 1 vertices vertically for rendering.

Signature:

const gridY: integer

depthWrite

Type: Field.

Description:

  Whether depth writes are enabled (default is false).

Signature:

depthWrite: boolean

texture

Type: Field.

Description:

  The texture used for the grid.

Signature:

texture: Texture2D

textureRect

Type: Field.

Description:

  The rectangle within the texture that is used for the grid.

Signature:

textureRect: Rect

blendFunc

Type: Field.

Description:

  The blending function used for the grid.

Signature:

blendFunc: BlendFunc

effect

Type: Field.

Description:

  The sprite effect applied to the grid. Default is SpriteEffect("builtin:vs_sprite", "builtin:fs_sprite").

Signature:

effect: SpriteEffect

setPos

Type: Function.

Description:

  Sets the position of a vertex in the grid.

Signature:

setPos: function(self: Grid, x: integer, y: integer, pos: Vec2, z?: number)

Parameters:

ParameterTypeDescription
xintegerThe x-coordinate of the vertex in the grid.
yintegerThe y-coordinate of the vertex in the grid.
posVec2The new position of the vertex.
znumber[optional] The z-coordinate of the vertex. Default is 0.

getPos

Type: Function.

Description:

  Gets the position of a vertex in the grid.

Signature:

getPos: function(self: Grid, x: integer, y: integer): Vec2

Parameters:

ParameterTypeDescription
xintegerThe x-coordinate of the vertex in the grid.
yintegerThe y-coordinate of the vertex in the grid.

Returns:

Return TypeDescription
Vec2The current position of the vertex.

getColor

Type: Function.

Description:

  Gets the color of a vertex in the grid.

Signature:

getColor: function(self: Grid, x: integer, y: integer): Color

Parameters:

ParameterTypeDescription
xintegerThe x-coordinate of the vertex in the grid.
yintegerThe y-coordinate of the vertex in the grid.

Returns:

Return TypeDescription
ColorThe current color of the vertex.

setColor

Type: Function.

Description:

  Sets the color of a vertex in the grid.

Signature:

setColor: function(self: Grid, x: integer, y: integer, color: Color)

Parameters:

ParameterTypeDescription
xintegerThe x-coordinate of the vertex in the grid.
yintegerThe y-coordinate of the vertex in the grid.
colorColorThe new color of the vertex.

moveUV

Type: Function.

Description:

  Moves the UV coordinates of a vertex in the grid.

Signature:

moveUV: function(self: Grid, x: integer, y: integer, offset: Vec2)

Parameters:

ParameterTypeDescription
xintegerThe x-coordinate of the vertex in the grid.
yintegerThe y-coordinate of the vertex in the grid.
offsetVec2The offset by which to move the UV coordinates.