angry-pixel 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +170 -168
  2. package/api-docs/.nojekyll +1 -0
  3. package/api-docs/assets/highlight.css +92 -0
  4. package/api-docs/assets/main.js +59 -0
  5. package/api-docs/assets/navigation.js +1 -0
  6. package/api-docs/assets/search.js +1 -0
  7. package/api-docs/assets/style.css +1383 -0
  8. package/api-docs/classes/Animator.html +128 -0
  9. package/api-docs/classes/AudioPlayer.html +131 -0
  10. package/api-docs/classes/BallCollider.html +132 -0
  11. package/api-docs/classes/BoxCollider.html +136 -0
  12. package/api-docs/classes/Button.html +125 -0
  13. package/api-docs/classes/Camera.html +114 -0
  14. package/api-docs/classes/Component.html +106 -0
  15. package/api-docs/classes/EdgeCollider.html +134 -0
  16. package/api-docs/classes/Game.html +24 -0
  17. package/api-docs/classes/GameCamera.html +163 -0
  18. package/api-docs/classes/GameObject.html +149 -0
  19. package/api-docs/classes/GamepadController.html +11 -0
  20. package/api-docs/classes/GamepadData.html +81 -0
  21. package/api-docs/classes/KeyboardController.html +43 -0
  22. package/api-docs/classes/MaskRenderer.html +119 -0
  23. package/api-docs/classes/MouseController.html +14 -0
  24. package/api-docs/classes/PhysicsComponent.html +107 -0
  25. package/api-docs/classes/PolygonCollider.html +134 -0
  26. package/api-docs/classes/PreRenderComponent.html +107 -0
  27. package/api-docs/classes/Rectangle.html +30 -0
  28. package/api-docs/classes/RigidBody.html +123 -0
  29. package/api-docs/classes/Rotation.html +5 -0
  30. package/api-docs/classes/Scene.html +73 -0
  31. package/api-docs/classes/SpacePointer.html +147 -0
  32. package/api-docs/classes/Sprite.html +20 -0
  33. package/api-docs/classes/SpriteRenderer.html +134 -0
  34. package/api-docs/classes/TextRenderer.html +138 -0
  35. package/api-docs/classes/TiledTilemapRenderer.html +127 -0
  36. package/api-docs/classes/TilemapCollider.html +124 -0
  37. package/api-docs/classes/TilemapRenderer.html +126 -0
  38. package/api-docs/classes/TouchController.html +8 -0
  39. package/api-docs/classes/Transform.html +124 -0
  40. package/api-docs/classes/Vector2.html +65 -0
  41. package/api-docs/classes/VideoRenderer.html +145 -0
  42. package/api-docs/enums/BroadPhaseMethods.html +3 -0
  43. package/api-docs/enums/ButtonType.html +3 -0
  44. package/api-docs/enums/CollisionMethods.html +3 -0
  45. package/api-docs/enums/RigidBodyType.html +4 -0
  46. package/api-docs/enums/TextOrientation.html +5 -0
  47. package/api-docs/enums/TilemapOrientation.html +5 -0
  48. package/api-docs/functions/between.html +5 -0
  49. package/api-docs/functions/clamp.html +5 -0
  50. package/api-docs/functions/fixedRound.html +4 -0
  51. package/api-docs/functions/randomFloat.html +4 -0
  52. package/api-docs/functions/randomInt.html +4 -0
  53. package/api-docs/functions/range.html +5 -0
  54. package/api-docs/index.html +37 -0
  55. package/api-docs/interfaces/AnimationConfig.html +10 -0
  56. package/api-docs/interfaces/AnimatorOptions.html +6 -0
  57. package/api-docs/interfaces/AudioPlayerOptions.html +8 -0
  58. package/api-docs/interfaces/BallColliderOptions.html +16 -0
  59. package/api-docs/interfaces/BoxColliderOptions.html +20 -0
  60. package/api-docs/interfaces/ButtonOptions.html +16 -0
  61. package/api-docs/interfaces/ColliderComponent.html +14 -0
  62. package/api-docs/interfaces/CollisionData.html +10 -0
  63. package/api-docs/interfaces/EdgeColliderOptions.html +18 -0
  64. package/api-docs/interfaces/GameConfig.html +28 -0
  65. package/api-docs/interfaces/IAssetManager.html +40 -0
  66. package/api-docs/interfaces/ICollider.html +11 -0
  67. package/api-docs/interfaces/ICollision.html +4 -0
  68. package/api-docs/interfaces/ICollisionResolution.html +4 -0
  69. package/api-docs/interfaces/IDomManager.html +6 -0
  70. package/api-docs/interfaces/IGameObjectManager.html +49 -0
  71. package/api-docs/interfaces/IInputManager.html +12 -0
  72. package/api-docs/interfaces/IPhysicsManager.html +8 -0
  73. package/api-docs/interfaces/IRenderManager.html +7 -0
  74. package/api-docs/interfaces/ISceneManager.html +18 -0
  75. package/api-docs/interfaces/ITimeManager.html +16 -0
  76. package/api-docs/interfaces/MaskRendererOptions.html +18 -0
  77. package/api-docs/interfaces/PolygonColliderOptions.html +18 -0
  78. package/api-docs/interfaces/RigidBodyOptions.html +17 -0
  79. package/api-docs/interfaces/Slice.html +5 -0
  80. package/api-docs/interfaces/SpriteConfig.html +10 -0
  81. package/api-docs/interfaces/SpriteRendererOptions.html +32 -0
  82. package/api-docs/interfaces/TextRendererOptions.html +38 -0
  83. package/api-docs/interfaces/TiledChunk.html +7 -0
  84. package/api-docs/interfaces/TiledLayer.html +17 -0
  85. package/api-docs/interfaces/TiledTilemap.html +9 -0
  86. package/api-docs/interfaces/TiledTilemapRendererOptions.html +18 -0
  87. package/api-docs/interfaces/TilemapColliderOptions.html +12 -0
  88. package/api-docs/interfaces/TilemapRendererOptions.html +22 -0
  89. package/api-docs/interfaces/Tileset.html +13 -0
  90. package/api-docs/interfaces/TouchInteraction.html +6 -0
  91. package/api-docs/interfaces/VideoRendererOptions.html +34 -0
  92. package/api-docs/modules.html +85 -0
  93. package/api-docs/types/CollisionMatrix.html +1 -0
  94. package/lib/component/Animator.d.ts +114 -8
  95. package/lib/component/AudioPlayer.d.ts +44 -6
  96. package/lib/component/Button.d.ts +82 -7
  97. package/lib/component/Camera.d.ts +27 -0
  98. package/lib/component/RigidBody.d.ts +75 -0
  99. package/lib/component/Transform.d.ts +35 -0
  100. package/lib/component/collider/BallCollider.d.ts +48 -0
  101. package/lib/component/collider/BoxCollider.d.ts +57 -0
  102. package/lib/component/collider/Collider.d.ts +51 -3
  103. package/lib/component/collider/EdgeCollider.d.ts +52 -0
  104. package/lib/component/collider/PolygonCollider.d.ts +53 -0
  105. package/lib/component/collider/TilemapCollider.d.ts +42 -0
  106. package/lib/component/rendering/MaskRenderer.d.ts +56 -0
  107. package/lib/component/rendering/Sprite.d.ts +61 -0
  108. package/lib/component/rendering/SpriteRenderer.d.ts +92 -2
  109. package/lib/component/rendering/TextRenderer.d.ts +103 -4
  110. package/lib/component/rendering/TiledTilemapRenderer.d.ts +114 -6
  111. package/lib/component/rendering/TilemapRenderer.d.ts +123 -7
  112. package/lib/component/rendering/VideoRenderer.d.ts +91 -1
  113. package/lib/core/Component.d.ts +118 -0
  114. package/lib/core/Game.d.ts +47 -2
  115. package/lib/core/GameActor.d.ts +20 -4
  116. package/lib/core/GameConfig.d.ts +45 -2
  117. package/lib/core/GameObject.d.ts +63 -0
  118. package/lib/core/Scene.d.ts +32 -0
  119. package/lib/core/ioc/Config.d.ts +2 -1
  120. package/lib/core/managers/AssetManager.d.ts +68 -6
  121. package/lib/core/managers/DomManager.d.ts +11 -0
  122. package/lib/core/managers/GameObjectManager.d.ts +81 -0
  123. package/lib/core/managers/HeadlessIterationManager.d.ts +1 -0
  124. package/lib/core/managers/IterationManager.d.ts +4 -0
  125. package/lib/core/managers/SceneManager.d.ts +29 -1
  126. package/lib/core/managers/TimeManager.d.ts +37 -2
  127. package/lib/gameObject/GameCamera.d.ts +22 -0
  128. package/lib/gameObject/SpacePointer.d.ts +7 -0
  129. package/lib/index.cjs.js +1 -1
  130. package/lib/index.d.ts +1 -1
  131. package/lib/index.esm.js +1 -1
  132. package/lib/index.js +1 -1
  133. package/lib/input/GamepadController.d.ts +176 -2
  134. package/lib/input/InputManager.d.ts +18 -0
  135. package/lib/input/KeyboardController.d.ts +70 -1
  136. package/lib/input/MouseController.d.ts +35 -0
  137. package/lib/input/TouchController.d.ts +36 -4
  138. package/lib/utils/Container.d.ts +1 -0
  139. package/lib/utils/Exception.d.ts +1 -0
  140. package/package.json +10 -6
  141. package/typedoc.json +13 -0
@@ -1,21 +1,77 @@
1
1
  import { RenderComponent } from "../../core/Component";
2
2
  import { Vector2, Rotation } from "angry-pixel-math";
3
+ /**
4
+ * MaskRenderer configuration options.
5
+ * @public
6
+ * @category Components
7
+ * @example
8
+ * ```js
9
+ * this.addComponent(MaskRenderer, {
10
+ * width: 32,
11
+ * height: 32,
12
+ * color: "#000000",
13
+ * offset: new Vector2(0, 0),
14
+ * rotation: new Rotation(0),
15
+ * opacity: 1,
16
+ * layer: "Mask",
17
+ * });
18
+ * ```
19
+ */
3
20
  export interface MaskRendererOptions {
21
+ /** Mask width in pixels */
4
22
  width: number;
23
+ /** Mask height in pixels */
5
24
  height: number;
25
+ /** The color of the mask */
6
26
  color: string;
27
+ /** X-axis and Y-axis offset */
7
28
  offset?: Vector2;
29
+ /** Mask rotation (degrees or radians) */
8
30
  rotation?: Rotation;
31
+ /** Change the opacity between 1 and 0 */
9
32
  opacity?: number;
33
+ /** The render layer */
10
34
  layer?: string;
11
35
  }
36
+ /**
37
+ * Renders a rectangle based on width, height and color
38
+ * @public
39
+ * @category Components
40
+ * @example
41
+ * ```js
42
+ * this.addComponent(MaskRenderer, {
43
+ * width: 32,
44
+ * height: 32,
45
+ * color: "#000000",
46
+ * });
47
+ * ```
48
+ * @example
49
+ * ```js
50
+ * this.addComponent(MaskRenderer, {
51
+ * width: 32,
52
+ * height: 32,
53
+ * color: "#000000",
54
+ * offset: new Vector2(0, 0),
55
+ * rotation: new Rotation(0),
56
+ * opacity: 1,
57
+ * layer: "Mask",
58
+ * });
59
+ * ```
60
+ */
12
61
  export declare class MaskRenderer extends RenderComponent {
62
+ /** Mask width in pixels */
13
63
  width: number;
64
+ /** Mask height in pixels */
14
65
  height: number;
66
+ /** The color of the mask */
15
67
  color: string;
68
+ /** X-axis and Y-axis offset */
16
69
  offset: Vector2;
70
+ /** Mask rotation (degrees or radians) */
17
71
  rotation: Rotation;
72
+ /** Change the opacity between 1 and 0 */
18
73
  opacity: number;
74
+ /** The render layer */
19
75
  layer: string;
20
76
  private renderData;
21
77
  private innerPosition;
@@ -0,0 +1,61 @@
1
+ import { Slice } from "angry-pixel-2d-renderer";
2
+ export { Slice };
3
+ /**
4
+ * Sprite configuration options
5
+ * @public
6
+ * @category Components
7
+ * @example
8
+ * ```js
9
+ * const sprite = new Sprite({
10
+ * image: this.assetManager.getImage("image.png"),
11
+ * slice: {x: 0, y:0, width: 16, height: 16},
12
+ * smooth: false
13
+ * });
14
+ * ```
15
+ */
16
+ export interface SpriteConfig {
17
+ /** The image element to render */
18
+ image: HTMLImageElement;
19
+ /** Cut the image based on straight coordinates starting from the top left downward */
20
+ slice?: Slice;
21
+ /** Smoothing pixels (not recommended for pixel art) */
22
+ smooth?: boolean;
23
+ }
24
+ /**
25
+ * The Sprite is an object that is composed of the Image element and allow to slice it and smooth its pixels.
26
+ * @public
27
+ * @category Components
28
+ * @example
29
+ * ```js
30
+ * const sprite = new Sprite({image: this.assetManager.getImage("image.png")});
31
+ * ```
32
+ * @example
33
+ * ```js
34
+ * const sprite = new Sprite({
35
+ * image: this.assetManager.getImage("image.png"),
36
+ * slice: {x: 0, y:0, width: 16, height: 16},
37
+ * smooth: false
38
+ * });
39
+ * ```
40
+ */
41
+ export declare class Sprite {
42
+ /** The image element to render */
43
+ readonly image: HTMLImageElement;
44
+ /** Cut the image based on straight coordinates starting from the top left downward */
45
+ readonly slice: Slice;
46
+ /** Smoothing pixels (not recommended for pixel art) */
47
+ readonly smooth: boolean;
48
+ private _width;
49
+ private _height;
50
+ private _loaded;
51
+ /**
52
+ * @param config The sprite configuration options
53
+ */
54
+ constructor(config: SpriteConfig);
55
+ /** The image width */
56
+ get width(): number;
57
+ /** The image height */
58
+ get height(): number;
59
+ /** TRUE if the image is loaded */
60
+ get loaded(): boolean;
61
+ }
@@ -1,39 +1,129 @@
1
1
  import { RenderComponent } from "../../core/Component";
2
- import { Sprite } from "../Sprite";
2
+ import { Sprite } from "./Sprite";
3
3
  import { Rotation, Vector2 } from "angry-pixel-math";
4
+ /**
5
+ * SpriteRenderer configuration options.
6
+ * @public
7
+ * @category Components
8
+ * @example
9
+ * ```js
10
+ * this.addComponent(SpriteRenderer, {
11
+ * sprite: new Sprite({image: this.assetManager.getImage("image.png")}),
12
+ * offset: new Vector2(0, 0),
13
+ * flipHorizontal: false,
14
+ * flipVertical: false,
15
+ * rotation: new Rotation(0),
16
+ * opacity: 1,
17
+ * tiled: new Vector2(1,1),
18
+ * maskColor: "#FF0000",
19
+ * maskColorMix: 0,
20
+ * tintColor: "#00FF00",
21
+ * layer: "Background",
22
+ * scale: new Vector2(1,1),
23
+ * width: 16,
24
+ * height: 16
25
+ * });
26
+ * ```
27
+ */
4
28
  export interface SpriteRendererOptions {
29
+ /** The sprite to render */
5
30
  sprite?: Sprite;
31
+ /** X-axis and Y-axis offset */
6
32
  offset?: Vector2;
33
+ /** Image rotation (degrees or radians) */
7
34
  rotation?: Rotation;
35
+ /** Flip the image horizontally */
8
36
  flipHorizontal?: boolean;
37
+ /** Flip the image vertically */
9
38
  flipVertical?: boolean;
39
+ /** Change the opacity between 1 and 0 */
10
40
  opacity?: number;
41
+ /** Render the image in tiles */
11
42
  tiled?: Vector2;
43
+ /** Define a mask color for the image */
12
44
  maskColor?: string;
45
+ /** Define the opacity of the mask color between 1 and 0 */
13
46
  maskColorMix?: number;
47
+ /** Define a color for tinting the sprite image */
14
48
  tintColor?: string;
49
+ /** The render layer */
15
50
  layer?: string;
51
+ /** Scale the image based on a vector */
52
+ scale?: Vector2;
53
+ /** Overwrite the original image width */
54
+ width?: number;
55
+ /** Overwrite the original image height */
56
+ height?: number;
16
57
  }
58
+ /**
59
+ * The SpriteRenderer component renders the Sprite and allows to configure options such as opacity, offser, color, etc.
60
+ * @public
61
+ * @category Components
62
+ * @example
63
+ * ```js
64
+ * this.addComponent(SpriteRenderer, {
65
+ * sprite: new Sprite({image: this.assetManager.getImage("image.png")})
66
+ * });
67
+ * ```
68
+ * @example
69
+ * ```js
70
+ * this.addComponent(SpriteRenderer, {
71
+ * sprite: new Sprite({image: this.assetManager.getImage("image.png")}),
72
+ * offset: new Vector2(0, 0),
73
+ * flipHorizontal: false,
74
+ * flipVertical: false,
75
+ * rotation: new Rotation(0),
76
+ * opacity: 1,
77
+ * tiled: new Vector2(1,1),
78
+ * maskColor: "#FF0000",
79
+ * maskColorMix: 0,
80
+ * tintColor: "#00FF00",
81
+ * layer: "Background",
82
+ * scale: new Vector2(1,1),
83
+ * width: 16,
84
+ * height: 16
85
+ * });
86
+ * ```
87
+ */
17
88
  export declare class SpriteRenderer extends RenderComponent {
18
89
  private readonly spriteDefaultScale;
90
+ /** The sprite to render */
19
91
  sprite: Sprite;
92
+ /** X-axis and Y-axis offset */
20
93
  offset: Vector2;
94
+ /** Flip the image horizontally */
21
95
  flipHorizontal: boolean;
96
+ /** Flip the image vertically */
22
97
  flipVertical: boolean;
98
+ /** Image rotation (degrees or radians) */
23
99
  rotation: Rotation;
100
+ /** Change the opacity between 1 and 0 */
24
101
  opacity: number;
25
- private _tiled;
102
+ /** Define a mask color for the image */
26
103
  maskColor: string;
104
+ /** Define the opacity of the mask color between 1 and 0 */
27
105
  maskColorMix: number;
106
+ /** Define a color for tinting the sprite image */
28
107
  tintColor: string;
108
+ /** The render layer */
29
109
  layer: string;
110
+ /** Scale the image based on a vector */
111
+ scale: Vector2;
112
+ /** Overwrite the original image width */
113
+ width: number;
114
+ /** Overwrite the original image height */
115
+ height: number;
116
+ private _tiled;
30
117
  private renderData;
31
118
  private innerPosition;
32
119
  private cachePosition;
33
120
  private cacheRenderPosition;
34
121
  private scaledOffset;
122
+ private cacheScale;
35
123
  protected init(config?: SpriteRendererOptions): void;
124
+ /** Render the image in tiles */
36
125
  get tiled(): Vector2;
126
+ /** Renders the image in tiles */
37
127
  set tiled(tiled: Vector2);
38
128
  protected update(): void;
39
129
  private updateRenderDataArray;
@@ -2,40 +2,139 @@ import { RenderComponent } from "../../core/Component";
2
2
  import { Rotation, Vector2 } from "angry-pixel-math";
3
3
  import { TextOrientation } from "angry-pixel-2d-renderer";
4
4
  export { TextOrientation };
5
+ /**
6
+ * TextRenderer configuration options.
7
+ * @public
8
+ * @category Components
9
+ * @example
10
+ * ```js
11
+ * this.addComponent(TextRenderer, {
12
+ * text: "Hello world",
13
+ * font: "Impact",
14
+ * fontSize: 16,
15
+ * width: 320,
16
+ * height: 32,
17
+ * color: "#FF0000",
18
+ * offset: new Vector2(0, 0),
19
+ * lineSeparation: 1,
20
+ * letterSpacing: 1,
21
+ * charRanges: [32, 126, 161, 255],
22
+ * smooth: false,
23
+ * rotation: new Rotation(0),
24
+ * opacity: 1,
25
+ * orientation: TextOrientation.RightDown
26
+ * bitmapMargin: new Vector2(0, 0),
27
+ * bitmapSpacing: new Vector2(0, 0),
28
+ * });
29
+ * ```
30
+ */
5
31
  export interface TextRendererOptions {
32
+ /** The text to render */
6
33
  text: string;
34
+ /** The font family to use */
7
35
  font: FontFace | string;
8
- fontSize?: number;
9
- color?: string;
36
+ /** The size of the font in pixels */
37
+ fontSize: number;
38
+ /** The text color */
39
+ color: string;
40
+ /** The width of the invisible box where the text is rendered */
41
+ width: number;
42
+ /** The height of the invisible box where the text is rendered */
43
+ height: number;
44
+ /** The separation between lines in pixels */
10
45
  lineSeparation?: number;
46
+ /** The space between chars in pixels */
11
47
  letterSpacing?: number;
12
- width?: number;
13
- height?: number;
48
+ /** X-axis and Y-axis offset */
14
49
  offset?: Vector2;
50
+ /** Range of characters covered by the component defined in number pairs.
51
+ * The default value is [32, 126, 161, 255], this means that characters
52
+ * from 32 to 126 and from 161 to 255 will be valid. */
15
53
  charRanges?: number[];
54
+ /** Smoothing pixels (not recommended for pixel art) */
16
55
  smooth?: boolean;
56
+ /** Text rotation (degrees or radians) */
17
57
  rotation?: Rotation;
58
+ /** Change the opacity between 1 and 0 */
18
59
  opacity?: number;
60
+ /** Direction in which the text will be rendered. */
19
61
  orientation?: TextOrientation;
62
+ /** Margin in pixels to correct badly sliced characters. */
20
63
  bitmapMargin?: Vector2;
64
+ /** Spacing in pixels to correct badly sliced characters. */
21
65
  bitmapSpacing?: Vector2;
22
66
  }
67
+ /**
68
+ * The TextRenderer component allows to render text using font families, colors, and other configuration options.
69
+ * @public
70
+ * @category Components
71
+ * @example
72
+ * ```js
73
+ * this.addComponent(TextRenderer, {
74
+ * text: "Hello world",
75
+ * font: "Impact",
76
+ * fontSize: 16,
77
+ * width: 320,
78
+ * height: 32,
79
+ * color: "#FF0000",
80
+ * });
81
+ * ```
82
+ * @example
83
+ * ```js
84
+ * this.addComponent(TextRenderer, {
85
+ * text: "Hello world",
86
+ * font: "Impact",
87
+ * fontSize: 16,
88
+ * width: 320,
89
+ * height: 32,
90
+ * color: "#FF0000",
91
+ * offset: new Vector2(0, 0),
92
+ * lineSeparation: 1,
93
+ * letterSpacing: 1,
94
+ * charRanges: [32, 126, 161, 255],
95
+ * smooth: false,
96
+ * rotation: new Rotation(0),
97
+ * opacity: 1,
98
+ * orientation: TextOrientation.RightDown
99
+ * bitmapMargin: new Vector2(0, 0),
100
+ * bitmapSpacing: new Vector2(0, 0),
101
+ * });
102
+ * ```
103
+ */
23
104
  export declare class TextRenderer extends RenderComponent {
105
+ /** The text to render */
24
106
  text: string;
107
+ /** The font family to use */
25
108
  font: FontFace | string;
109
+ /** The size of the font in pixels. */
26
110
  fontSize: number;
111
+ /** The width of the invisible box where the text is rendered */
27
112
  width: number;
113
+ /** The height of the invisible box where the text is rendered */
28
114
  height: number;
115
+ /** X-axis and Y-axis offset */
29
116
  offset: Vector2;
117
+ /** The text color */
30
118
  color: string;
119
+ /** The separation between lines in pixels */
31
120
  lineSeparation: number;
121
+ /** The space between chars in pixels */
32
122
  letterSpacing: number;
123
+ /** Range of characters covered by the component defined in number pairs.
124
+ * The default value is [32, 126, 161, 255], this means that characters
125
+ * from 32 to 126 and from 161 to 255 will be valid. */
33
126
  charRanges: number[];
127
+ /** Smoothing pixels (not recommended for pixel art) */
34
128
  smooth: boolean;
129
+ /** Text rotation (degrees or radians) */
35
130
  rotation: Rotation;
131
+ /** Change the opacity between 1 and 0 */
36
132
  opacity: number;
133
+ /** Direction in which the text will be rendered. */
37
134
  orientation: TextOrientation;
135
+ /** Margin in pixels to correct badly sliced characters. */
38
136
  bitmapMargin: Vector2;
137
+ /** Spacing in pixels to correct badly sliced characters. */
39
138
  bitmapSpacing: Vector2;
40
139
  private renderData;
41
140
  private lastFrameText;
@@ -1,26 +1,133 @@
1
1
  import { RenderComponent } from "../../core/Component";
2
2
  import { ITilemapRenderer, Tileset, TilemapOrientation } from "./TilemapRenderer";
3
+ /**
4
+ * TiledTilemapRenderer configuration options
5
+ * @public
6
+ * @category Components
7
+ * @example
8
+ * ```js
9
+ * import TilemapData from "export.json";
10
+ *
11
+ * this.addComponent(TilemapRenderer, {
12
+ * tileset: {
13
+ * image: this.assetManager.getImage("image.png"),
14
+ * width: 3,
15
+ * tileWidth: 16,
16
+ * tileHeight: 16,
17
+ * margin: new Vector2(0, 0),
18
+ * spacing: new Vector2(0, 0),
19
+ * }
20
+ * tiledData: TilemapData,
21
+ * tilemapLayer: "Layer1",
22
+ * tileWidth: 16,
23
+ * tileHeight: 16,
24
+ * layer: "Tilemap",
25
+ * orientation: TilemapOrientation.Center,
26
+ * smooth: false,
27
+ * });
28
+ * ```
29
+ */
3
30
  export interface TiledTilemapRendererOptions {
31
+ /** Export of the Tiles application in JSON */
4
32
  tiledData: TiledTilemap;
33
+ /** The Tiled tilemap layer to render */
5
34
  tilemapLayer: string;
35
+ /** The Tileset instance */
6
36
  tileset: Tileset;
7
- tileWidth: number;
8
- tileHeight: number;
37
+ tileWidth?: number;
38
+ tileHeight?: number;
39
+ /** The render layer */
9
40
  layer?: string;
41
+ /** Direction in which the tilemap will be rendered. */
10
42
  orientation?: TilemapOrientation;
43
+ /** Smoothing pixels (not recommended for pixel art) */
11
44
  smooth?: boolean;
12
45
  }
46
+ /**
47
+ * The TiledTilemapRenderer component allows you to render a tile map exported from the Tiled application,
48
+ * using an instance of the TileSet object.
49
+ * @public
50
+ * @category Components
51
+ * @example
52
+ * ```js
53
+ * import TilemapData from "export.json";
54
+ *
55
+ * this.addComponent(TiledTilemapRenderer, {
56
+ * tileset: {
57
+ * image: this.assetManager.getImage("image.png"),
58
+ * width: 3,
59
+ * tileWidth: 16,
60
+ * tileHeight: 16,
61
+ * }
62
+ * tiledData: TilemapData,
63
+ * tilemapLayer: "Layer1",
64
+ * tileWidth: 16,
65
+ * tileHeight: 16,
66
+ * });
67
+ * ```
68
+ * @example
69
+ * ```js
70
+ * import TilemapData from "export.json";
71
+ *
72
+ * this.addComponent(TilemapRenderer, {
73
+ * tileset: {
74
+ * image: this.assetManager.getImage("image.png"),
75
+ * width: 3,
76
+ * tileWidth: 16,
77
+ * tileHeight: 16,
78
+ * margin: new Vector2(0, 0),
79
+ * spacing: new Vector2(0, 0),
80
+ * }
81
+ * tiledData: TilemapData,
82
+ * tilemapLayer: "Layer1",
83
+ * tileWidth: 16,
84
+ * tileHeight: 16,
85
+ * layer: "Tilemap",
86
+ * orientation: TilemapOrientation.Center,
87
+ * smooth: false,
88
+ * });
89
+ * ```
90
+ */
13
91
  export declare class TiledTilemapRenderer extends RenderComponent implements ITilemapRenderer {
92
+ private readonly spriteDefaultScale;
93
+ /**
94
+ * Id of tiles separated by commas. The ids start at 1, and increment from left to right,
95
+ * from top to bottom. ID 0 (zero) represents a space with no tile.
96
+ * @readonly
97
+ */
14
98
  tiles: number[];
99
+ /** The width of the tile to render in pixels */
15
100
  tileWidth: number;
101
+ /** The height of the tile to render in pixels */
16
102
  tileHeight: number;
103
+ /**
104
+ * The width of the tilemap in tiles (this is calculated by the component)
105
+ * @readonly
106
+ */
17
107
  width: number;
108
+ /**
109
+ * The height of the tilemap in tiles (this is calculated by the component)
110
+ * @readonly
111
+ */
18
112
  height: number;
113
+ /** Direction in which the tilemap will be rendered (default value TilemapOrientation.Center) */
19
114
  orientation: TilemapOrientation;
115
+ /** Define a color for tinting the tiles */
20
116
  tintColor: string;
21
- alpha: number;
117
+ /** Change the opacity between 1 and 0 */
118
+ opacity: number;
119
+ /**
120
+ * Tilemap width in pixels (this is calculated by the component)
121
+ * @readonly
122
+ */
123
+ realWidth: number;
124
+ /**
125
+ * Tilemap height in pixels (this is calculated by the component)
126
+ * @readonly
127
+ */
128
+ realHeight: number;
22
129
  private tiledData;
23
- private tilemapLayer;
130
+ private tiledLayer;
24
131
  private tileset;
25
132
  private layer;
26
133
  private smooth?;
@@ -28,8 +135,6 @@ export declare class TiledTilemapRenderer extends RenderComponent implements ITi
28
135
  private chunks;
29
136
  private scaledTileWidth;
30
137
  private scaledTileHeight;
31
- realWidth: number;
32
- realHeight: number;
33
138
  private renderData;
34
139
  protected init({ tiledData, tilemapLayer, tileset, tileWidth, tileHeight, layer, orientation, smooth, }: TiledTilemapRendererOptions): void;
35
140
  protected update(): void;
@@ -38,6 +143,7 @@ export declare class TiledTilemapRenderer extends RenderComponent implements ITi
38
143
  private getTilesetTileId;
39
144
  private updateRenderData;
40
145
  }
146
+ /** @category Components */
41
147
  export interface TiledTilemap {
42
148
  width: number;
43
149
  height: number;
@@ -50,6 +156,7 @@ export interface TiledTilemap {
50
156
  tilewidth: number;
51
157
  tileheight: number;
52
158
  }
159
+ /** @category Components */
53
160
  export interface TiledChunk {
54
161
  data: number[];
55
162
  x: number;
@@ -58,6 +165,7 @@ export interface TiledChunk {
58
165
  height: number;
59
166
  type?: string;
60
167
  }
168
+ /** @category Components */
61
169
  export interface TiledLayer {
62
170
  name: string;
63
171
  id: number;