Skip to content

Latest commit

 

History

History
63 lines (49 loc) · 3.43 KB

File metadata and controls

63 lines (49 loc) · 3.43 KB

☑️ Phaser.GameObject.Mesh

In case of doubt, the official source code should be accessed.

Example

let newMesh = this.add.mesh(
  300,
  300,
  [-250, -250, -250, 250, 250, 250, -250, -250, 250, 250, 250, -250],
  [0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0],
  [0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff],
  [1, 1, 1, 1, 1, 1],
  "texture"
);

You can access and manipulate the vertices with newMesh.vertices[0], newMesh.vertices[1] etc.

You can access and manipulate the uvs with newMesh.uv[0], newMesh.uv[1] etc.

Parameters

x                    : the x position of the mesh
y                    : the y position of the mesh
vertices             : array of x and y positions relative to center of mesh object
uv                   : mapping of the uv coordinates
colors               : array of colors for each uv texture coordinate
alphas               : array of alphas for each uv texture coordinate
texture              : sprite name
frame                : the sprite frame

When you render a standard Sprite in WebGL it consists of 2 triangles drawn as a quad. The texture is mapped using the UV coordinates.

The exact positions in the coordinate system (x and y) are specified under vertices

The texture coordinates (U and V = UV) are defined in uv

Extends

Mixins