Sprites
Sprites are visual assets used to represent new items, enemies, or any other object displayed on the screen.
Root folder: ../datafiles/mods/mod-name/sprites/
Sprite configurations are stored in one or more .json files located in the root folder. Each .json file may contain one or more sprite definitions.
| Parameter | Description | Example | Default |
|---|---|---|---|
| key | The unique identifier of the new sprite. | spr_mod_name_sprite_name | n/a |
| file | The path to the sprite file. The image used for the sprite definition may be placed in a subfolder. | weapons/mod_weapon_bow/icon.png | n/a |
| imgnum | (optional) The number of frames | 4 | 1 |
| removeback | (optional) Indicates whether to make all pixels with the background colour (left-bottom pixel) transparent. | 1 | 0 |
| smooth | (optional) Indicates whether to smooth the edges if transparent. | 1 | 0 |
| xorig | (optional) Indicate the x position of the origin in the sprite. | 16 | 0 |
| yorig | (optional) Indicate the y position of the origin in the sprite. | 16 | 0 |
| bbox | (optional) Specifies the bounding box of the sprite used for collision checks. When setting the “bbox” parameter, the bbox_mode is automatically set to “bboxmode_manual”. bbox_left, bbox_top, bbox_right and bbox_bottom are mandatory, when setting the bbox manually. | { „bbox_left“: 8, „bbox_top“: 42, „bbox_right“: 23, „bbox_bottom“: 57 } | The full image is used if not bbox is defined. |
| speed | (optional) Sets the speed. The sprite was defined with in animation in frames per game frame. | 0.5 | 1 |
Best practices
Each sprite must be assigned a unique key. To prevent conflicts with other mods or base assets, it is recommended to use a composite naming scheme that includes the mod identifier (e.g. „immersive_equipment“) and the sprite’s descriptive name (e.g. „weapon_hunter_bow_attack“). A consistent prefix such as „spr_“ can further help distinguish sprite assets.
Example Sprite Definition
[
{
"key": "spr_immersive_equipment_weapon_hunter_bow_attack",
"file": "weapons/hunter_bow/atk_strip9.png",
"imgnum": 9,
"removeback": 0,
"smooth": 0,
"xorig": 32,
"yorig": 44
},
{
"key": "spr_immersive_equipment_weapon_hunter_bow_idle",
"file": "weapons/hunter_bow/idle_strip6.png",
"imgnum": 6,
"xorig": 32,
"yorig": 44
},
{
"key": "spr_immersive_equipment_weapon_hunter_bow_move",
"file": "weapons/hunter_bow/move_strip6.png",
"imgnum": 6,
"xorig": 32,
"yorig": 44
}
]
Sprite Constraints
Some sprites require a certain amount of frames, to be rendered correctly.
| Animation | Number of Frames |
|---|---|
| attack (bow) | 9 |
| attack (greatsword) | 11 |
| attack (rapier) | 5 |
| attack (spear) | 8 |
| attack (staff) | 8 |
| attack (sword) | 6 |
| backstep | 3 |
| death | 5 |
| dodge | 4 |
| idle | 6 |
| move | 6 |
| cast (default) | 6 |
| cast (throw) | 7 |
External Resources
See Game Maker documentation for further information: https://manual.gamemaker.io/beta/en/GameMaker_Language/GML_Reference/Asset_Management/Sprites/Sprite_Manipulation/sprite_add.htm