Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

SpriteAnimation

Tom Hancocks edited this page Dec 17, 2019 · 4 revisions

The SpriteAnimation resource is used to encode animation information about a given sprite. It references a single image resource and specifies how the image should be divided and the geometry of each individual frame.

The following represents a source image.

┏━━━━━━━━━━━━━┓ ↑
┃             ┃
┃             ┃
┃             ┃
┃             ┃ ?
┃             ┃
┃             ┃
┃             ┃
┗━━━━━━━━━━━━━┛ ↓
←      ?      →

If the SpriteAnimation defines the size of a frame, and the number of frames that fit into both the horizontal and vertical dimensions, then the engine can infer where each of the frames exist within the source image.

┏━━━━━━┳━━━━━━┓ 
┃      ┃      ┃ ↑
┃      ┃      ┃ y
┃      ┃      ┃ ↓
┣━━━━━━╋━━━━━━┫ 
┃      ┃      ┃ ↑
┃      ┃      ┃ y
┃      ┃      ┃ ↓
┗━━━━━━┻━━━━━━┛ 
 ← x →   ← x →

Resource Information

Attribute Value
KDL Identifier SpriteAnimation
Resource Type Code spïn
Supported Engines EV Nova, Kestrel
Binary Size 12 bytes

KDL Usage

Field Name Type Description
sprites resource_reference A reference to the image resource that should be used for the sprites.
masks resource_reference A reference to the image resource that should be used for the sprite masks. This field is deprecated in Kestrel, but required for Nova.
size integer, integer Defines the size of the frames of the sprite. The first value specified is the width, the second is the height.
tiles integer, integer Defines the number of the frames in the horizontal and vertical axises within the source image. The first value specified is the number of frames in the horizontal direction, the second is the number of frames in the vertical direction.

An example of how this resource is used in KDL is

declare SpriteAnimation {
    new (id = #128, name = "Example Sprite") {
        sprites = #128; ` Use PICT #128 as the source
        size = 50 50; ` Each frame is 50x50px
        tiles = 6 6; ` The source image is comprised of 6 x 6 frames (36 total)
    }
}

Binary Format

Field Name Offset Size Type Description
Sprites ID 0 2 word The ID of the image resource to use for the sprites.
Masks ID 2 2 word The ID of the image resource to user as a mask for the sprites. This field is deprecated in Kestrel, but required for Nova.
Frame Width 4 2 word The width of a single frame in the animation.
Frame Height 6 2 word The height of a single frame in the animation.
X Tiles 8 2 word The number of sprites positioned along the horizontal axis of the source image.
Y Tiles 10 2 word The number of sprites positioned along the vertical axis of the source image.
Clone this wiki locally