Skip to content

Pack Sprites

Mark7625 edited this page Apr 30, 2024 · 2 revisions

Pack Sprites

This task is responsible for packing sprite images into an OSRS game cache. It supports both single sprite files and spritesheets, automatically handling different packing strategies based on the provided manifest file. This class is a part of the cache update process, ensuring that all new or modified sprites are correctly encoded and stored in the game's cache system.

Usage

Sprite Manifest Configuration Properties:

  • spritesDirectory: A File object pointing to the directory that contains the sprite images you want to pack.

  • spriteManifest: A File object pointing to a TOML file that serves as the manifest. This file is optional and provides metadata about the sprites to assist in the packing process.

PackSprites(spritesDirectory = File("path/to/sprites"))

Optionally, you can also provide a sprite manifest file that contains additional information about the sprites, such as offsets, whether the sprite is part of an atlas, or identifiers for named sprites.

PackSprites(spritesDirectory = File("path/to/sprites"), spriteManifest = File("path/to/manifest.toml"))

Manifest Values:

  • [name]: This name should be equal to your file name with no extension.
  • id: ID or 'Group' you wish to pack. This value is required.
  • offsetX: An offset on the X for your sprite (Optional).
  • offsetY: An offset on the Y for your sprite (Optional).
  • atlas: If you want an atlas, you will need to define this (Optional). Atlas Values:
    • width: Width of a single sprite in your atlas.
    • height: Height of a single sprite in your atlas.

Example of a sprite manifest (spriteManifest.toml):

[worldmap]
id = 1439

[mapscene]
id = 317
[mapscene.atlas]
 width = 8
 height = 8

Note: If no manifest is provided, the tool will pack only non-named sprites, such as [37_5, 1440]

image

Documentation

Clone this wiki locally