Phaser API Documentation


Member of: Phaser.Geom.Mesh

<static> GenerateGridVerts(config)


Creates a grid of vertices based on the given configuration object and optionally adds it to a Mesh.

The size of the grid is given in pixels. An example configuration may be:

{ width: 256, height: 256, widthSegments: 2, heightSegments: 2, tile: true }

This will create a grid 256 x 256 pixels in size, split into 2 x 2 segments, with the texture tiling across the cells.

You can split the grid into segments both vertically and horizontally. This will generate two faces per grid segment as a result.

The tile parameter allows you to control if the tile will repeat across the grid segments, or be displayed in full.

If adding this grid to a Mesh you can offset the grid via the x and y properties.

UV coordinates are generated based on the given texture and frame in the config. For example, no frame is given, the UVs will be in the range 0 to 1. If a frame is given, such as from a texture atlas, the UVs will be generated within the range of that frame.


name type description
config Phaser.Types.Geom.Mesh.GenerateGridConfig

A Grid configuration object.


A Grid Result object, containing the generated vertices and indicies.

Since: 3.50.0