Skip to content

Sprites

Texture Atlases (Sprite Sheets)

Packed texture atlases created with the tool Free Texture Packer (FTP) are supported and can be loaded with yg.asset.loadTexture().

Tested with Free Texture Packer v0.6.7.

The following FTP settings are required. The rest can be set to users taste.

  • Format: JSON (hash) or JSON (array)
  • Allow rotation: No
  • Allow trim: No
  • Padding: >= 2 (recommended)

Accessing Sprites and Sequences

To draw a sprite from a texture atlas, the draw function must know where to find the desired sprite in the texture. The following functions can be used on a yg.gl.Texture to retrieve these coordinate information.

During texture loading, sequences are detected if the sprite names have indexes at the end, separated with - or _.

Examples: