-
Notifications
You must be signed in to change notification settings - Fork 1
/
SpriteDefinition.ts
83 lines (82 loc) · 2.03 KB
/
SpriteDefinition.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Size } from './Size';
import { TilePosition } from './TilePosition';
/**
* Definition of a sprite to be used in the tilemap.
*
* The sprite is defined by a list of images that will be used as frames.
*
* The first image will be used as the default image.
*
* The rest of the images will be used for animation.
*
* If there is only one image, the animation will be disabled.
*
* The images must have the same size.
*
* @example
*
* const spriteDefinition = {
* key: "my-sprite",
* imagesSrc: [
* "https://example.com/image1.png",
* "https://example.com/image2.png",
* "https://example.com/image3.png",
* ],
* animationDelay: 1000,
* tileSize: { width: 1, height: 1 },
* };
*
* @public
*/
export type SpriteDefinition = {
/**
* Unique key to identify the sprite.
*/
key: string;
/**
* List of image sources to be used as sprite frames.
*
* The first image will be used as the default image.
*
* The rest of the images will be used for animation.
*
* If there is only one image, the animation will be disabled
* The images must have the same size.
*
* @example
* imagesSrc: [
* "https://example.com/image1.png",
* "https://example.com/image2.png",
* "https://example.com/image3.png",
* ],
*/
imagesSrc: string[];
/**
* Delay in milliseconds between each animation frame.
*
* If not provided, the default value will be used.
*
* If there is only one image, the animation will be disabled.
*
* The delay must be greater than 0.
*
* @default 1000
*/
animationDelay?: number;
/**
* Sprite's size in tiles. Indicates how many tiles the sprite will occupy.
*
* If not provided, the default value will be used.
*
* The size width and height must be greater than 0.
*
* @default { width: 1, height: 1 }
*/
size?: Size;
/**
* Sprite's offset in tiles. Indicates how many tiles the sprite will be offset from it origin.
*
* @default { col: 0, row: 0 }
*/
offset?: TilePosition;
};