rapid-render 0.1.1 → 0.1.2-1.3

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.
package/README.md CHANGED
@@ -1,126 +1,88 @@
1
- # 🚀 Rapid.js
1
+ > [!WARNING]
2
+ > **🚧 Major Refactoring in Progress 🚧**
3
+ >
4
+ > This project is currently undergoing a significant rewrite to improve its core architecture and introduce new features. As a result, the **current documentation and examples are outdated** and may not work with the `main` branch.
5
+ >
6
+ > We are working hard to update the documentation soon. Thank you for your patience!
2
7
 
3
- A highly efficient and lightweight WebGL renderer
8
+ # Rapid.js
4
9
 
5
- ## [API Docs](https://nightre.github.io/Rapid.js/docs/)
10
+ A highly efficient ([stress-test](https://nightre.github.io/Rapid.js/docs/examples.html)) and lightweight WebGL-based 2D rendering engine focused on rendering capabilities.
6
11
 
7
- [stress test demo](https://nightre.github.io/Rapid.js/demo/) ( [source code](./demo/index.js) )
12
+ ### [Website](https://nightre.github.io/Rapid.js/docs/index.html)
8
13
 
9
- [render demo](https://nightre.github.io/Rapid.js/demo/matrix_stack.html) ( [source code](./demo/matrix_stack.js) )
14
+ #### [Document](https://nightre.github.io/Rapid.js/docs/docs.html) | [API Docs](https://nightre.github.io/Rapid.js/docs/api/index.html) | [Examples](https://nightre.github.io/Rapid.js/docs/examples.html)
10
15
 
11
- [custom shader demo](https://nightre.github.io/Rapid.js/demo/custom-shader.html) ( [source code](./demo/custom-shader.js) )
16
+ ## Features
12
17
 
18
+ * **Fast Rendering** ⚡
19
+ * **TileMap** - YSort, isometric 🗺️
20
+ * **Light Shadow** 💡
21
+ * **Particle** 🎆
22
+ * **Camera** 🎥
23
+ * **Graphics Drawing** ✏️
24
+ * **Text Rendering** 📝
25
+ * **Line Drawing** - line texture 〰️
26
+ * **Custom Shaders** 🎨
27
+ * **Mask** 🎭
28
+ * **Frame Buffer Object** 🖼️
13
29
 
30
+ ## Performance Testing
14
31
 
15
- # Features
16
- * **Fast Rendering**: Render 10,000 sprites at 60fps
17
- * **Multi-Texture Support**: Batch rendering using GPU's maximum texture units
18
- * **Graphics Drawing**
19
- * **Matrix Stack**
20
- * **Text Rendering**
21
- * **Line Drawing**
22
- * **Custom Shaders**
23
- * **Texture Clipping**
32
+ 32x32 Texture Sprites 60FPS
24
33
 
25
- # Install
34
+ * `Intel® Iris® Xe Graphics` : 42K sprites
26
35
 
27
- ```
36
+ ## Install
37
+
38
+ ```bash
28
39
  npm i rapid-render
29
40
  ```
30
41
 
31
- Or use unpkg
42
+ Or via CDN:
32
43
 
33
44
  ```html
34
45
  <script src="https://unpkg.com/rapid-render/dist/rapid.umd.cjs"></script>
35
46
  ```
36
47
 
37
- # Import
48
+ ## Quick Start
38
49
 
39
50
  ```js
40
- import { Rapid } from "rapid-render"
41
- ```
42
-
43
- # Useage
44
-
45
- ```js
46
- let rapid = new Rapid({
47
- canvas: document.getElementById("game"),
48
- backgroundColor: Color.fromHex("FFFFFF")
49
- });
50
-
51
- // Create texture
52
- const cat = await rapid.textures.textureFromUrl("./cat.png");
53
- // R G B A
54
- const color = new Color(255, 255, 255, 255); // Or use Color.fromHex
55
-
56
- // Call before rendering
57
- rapid.startRender();
58
-
59
- // Render here...
60
-
61
- // Call after rendering
62
- rapid.endRender();
63
-
64
- // Set canvas size
65
- rapid.resize(100, 100);
51
+ import { Rapid, Color, Vec2 } from "rapid-render"
52
+
53
+ // Initialize
54
+ const rapid = new Rapid({
55
+ canvas: document.getElementById("gameCanvas"),
56
+ backgroundColor: Color.fromHex("E6F0FF")
57
+ })
58
+
59
+ // Render example
60
+ rapid.render(() => {
61
+ rapid.renderRect({
62
+ offset: new Vec2(100, 100),
63
+ width: 50,
64
+ height: 50,
65
+ color: Color.Red
66
+ })
67
+ })
66
68
  ```
67
69
 
68
- # Render
70
+ For more examples and detailed documentation, visit our [website](https://nightre.github.io/Rapid.js/docs/index.html).
69
71
 
70
- ```js
71
- const text = rapid.textures.createText({ text: "Hello!", fontSize: 30 })
72
+ ## Roadmap
72
73
 
73
- rapid.save() // Save state
74
- rapid.matrixStack.translate(0,0)
75
- rapid.matrixStack.scale(1)
76
- rapid.matrixStack.rotate(0)
74
+ * 9-slice 🚧 (In Progress)
75
+ * Nodejs Support
77
76
 
78
- // Render Sprit
79
- rapid.renderSprite(cat, 0, 0, color) // or rapid.renderSprite(cat, 0, 0, { color })
77
+ ## Contributing
80
78
 
81
- // Rendr Graphic
82
- const path = Vec2.FormArray([[0, 0], [100, 0], [100, 100]])
83
- rapid.renderGraphic(0,0,{points:path, color:green})
84
- // or
85
- // rapid.startGraphicDraw()
86
- // rapid.addGraphicVertex(0, 0, color)
87
- // rapid.endGraphicDraw()
79
+ Issues and PRs are welcome!
88
80
 
89
- // Render Text
90
- rapid.renderSprite(text, 200, 0)
91
- text.setText("time:" + Math.round(time))
92
-
93
- rapid.restore() // back to the previous saved state
94
- ```
81
+ ## Screen shot
95
82
 
96
- # Custom Shader
97
-
98
- View demo and watch detailed shader code [custom shader demo](https://nightre.github.io/Rapid.js/demo/custom-shader.html) ( [source code](./demo/custom-shader.js) )
99
-
100
- ```js
101
- const vertexShaderSource = `...`
102
- const fragmentShaderSource = `...`
103
-
104
- const customShader = new GLShader(rapid, vertexShaderSource, fragmentShaderSource)
105
- rapid.startRender()
106
-
107
- rapid.renderSprite(plane, 100, 100, {
108
- shader: customShader, // shader
109
- uniforms: {
110
- // Set custom uniform (You can set mat3, vec2, and so on here)
111
- uCustomUniform: Number(costumUniformValue)
112
- // uVec2Uniform: [0,2] // recognized as vec2
113
- // uMat3Uniform: [
114
- // [0,0,0],
115
- // [0,0,0],
116
- // [0,0,0],
117
- // ]
118
- // recognized as mat3
119
- }
120
- });
121
-
122
- rapid.endRender()
123
- ```
124
- # Screen Shot
83
+ ![1](./screenshot/1.gif)
84
+ ![2](./screenshot/2.gif)
85
+ ![3](./screenshot/3.png)
86
+ ![4](./screenshot/4.png)
87
+ ![4](./screenshot/5.png)
125
88
 
126
- ![screen](./screenshot/screen.png)
@@ -0,0 +1,93 @@
1
+ import { AudioPlayer } from './audio';
2
+ import { Game } from './game';
3
+ import { IAsset, IAssets } from './interface';
4
+ import { default as EventEmitter } from 'eventemitter3';
5
+ /**
6
+ * Events emitted by AssetsLoader.
7
+ */
8
+ interface AssetsLoaderEvents {
9
+ progress: (progress: number, loaded: number, total: number) => void;
10
+ complete: (assets: IAssets) => void;
11
+ error: (error: {
12
+ name: string;
13
+ url: string;
14
+ error: any;
15
+ }) => void;
16
+ }
17
+ /**
18
+ * AssetsLoader class for loading game assets (JSON, audio, images).
19
+ * Supports asynchronous loading with progress tracking and error handling.
20
+ */
21
+ declare class AssetsLoader extends EventEmitter<AssetsLoaderEvents> {
22
+ private assets;
23
+ private totalAsset;
24
+ private loadedAssets;
25
+ private game;
26
+ /**
27
+ * Creates an instance of AssetsLoader.
28
+ * Initializes the asset storage and counters.
29
+ */
30
+ constructor(game: Game);
31
+ /**
32
+ * Loads a JSON file asynchronously.
33
+ * @param name - The unique identifier for the JSON asset.
34
+ * @param url - The URL of the JSON file.
35
+ */
36
+ loadJson(name: string, url: string): void;
37
+ /**
38
+ * Loads an audio file asynchronously using the AudioManager.
39
+ * The AudioManager will handle fetching and caching.
40
+ * @param name - The unique identifier for the audio asset.
41
+ * @param url - The URL of the audio file.
42
+ */
43
+ loadAudio(name: string, url: string): Promise<void>;
44
+ /**
45
+ * Loads an image file asynchronously using the TextureManager.
46
+ * @param name - The unique identifier for the image asset.
47
+ * @param url - The URL of the image file.
48
+ */
49
+ loadImage(name: string, url: string): Promise<void>;
50
+ /**
51
+ * Loads multiple assets from a list.
52
+ * @param assetList - Array of assets to load.
53
+ */
54
+ loadAssets(assetList: IAsset[]): void;
55
+ /**
56
+ * Handles the completion of an asset load.
57
+ * Updates progress and triggers completion event if all assets are loaded.
58
+ */
59
+ private assetLoaded;
60
+ /**
61
+ * Handles errors during asset loading.
62
+ * @param name - The name of the asset.
63
+ * @param url - The URL of the asset.
64
+ * @param error - The error object or message.
65
+ */
66
+ private handleError;
67
+ /**
68
+ * Retrieves a loaded asset by type and name.
69
+ * @param type - The type of asset ('json', 'audio', or 'images').
70
+ * @param name - The name of the asset.
71
+ * @returns The loaded asset or undefined if not found.
72
+ */
73
+ get<T extends keyof IAssets>(type: T, name: string): IAssets[T][string] | undefined;
74
+ /**
75
+ * Retrieves a loaded JSON asset by name.
76
+ * @param name - The name of the JSON asset.
77
+ * @returns The loaded JSON data or undefined if not found.
78
+ */
79
+ getJSON(name: string): any | undefined;
80
+ /**
81
+ * Retrieves a loaded audio asset by name.
82
+ * @param name - The name of the audio asset.
83
+ * @returns The loaded AudioPlayer instance or undefined if not found.
84
+ */
85
+ getAudio(name: string): AudioPlayer | undefined;
86
+ /**
87
+ * Retrieves a loaded texture (image) asset by name.
88
+ * @param name - The name of the texture asset.
89
+ * @returns The loaded texture or undefined if not found.
90
+ */
91
+ getTexture(name: string): any | undefined;
92
+ }
93
+ export default AssetsLoader;
@@ -0,0 +1,81 @@
1
+ import { default as EventEmitter } from 'eventemitter3';
2
+ /**
3
+ * Events emitted by AudioPlayer.
4
+ */
5
+ interface AudioPlayerEvents {
6
+ ended: () => void;
7
+ }
8
+ /**
9
+ * Represents a single, playable audio instance.
10
+ * Created by the AudioManager.
11
+ */
12
+ export declare class AudioPlayer extends EventEmitter<AudioPlayerEvents> {
13
+ private audioContext;
14
+ private audioBuffer;
15
+ private sourceNode;
16
+ private gainNode;
17
+ private _volume;
18
+ private _loop;
19
+ private _isPlaying;
20
+ constructor(audioContext: AudioContext, audioBuffer: AudioBuffer);
21
+ /**
22
+ * Plays the audio. If already playing, it will stop the current playback and start over.
23
+ */
24
+ play(): void;
25
+ /**
26
+ * Stops the audio playback immediately.
27
+ */
28
+ stop(): void;
29
+ /**
30
+ * Gets the volume of the audio, from 0.0 to 1.0.
31
+ */
32
+ get volume(): number;
33
+ /**
34
+ * Sets the volume of the audio.
35
+ * @param value - The volume, from 0.0 (silent) to 1.0 (full).
36
+ */
37
+ set volume(value: number);
38
+ /**
39
+ * Gets whether the audio will loop.
40
+ */
41
+ get loop(): boolean;
42
+ /**
43
+ * Sets whether the audio should loop.
44
+ * Can be changed while the audio is playing.
45
+ */
46
+ set loop(value: boolean);
47
+ /**
48
+ * Gets whether the audio is currently playing.
49
+ */
50
+ get isPlaying(): boolean;
51
+ /**
52
+ * Stops playback, disconnects audio nodes, and removes all event listeners.
53
+ * This makes the AudioPlayer instance unusable.
54
+ */
55
+ destroy(): void;
56
+ }
57
+ /**
58
+ * Manages loading, decoding, and caching of audio assets.
59
+ * This is analogous to your TextureCache.
60
+ */
61
+ export declare class AudioManager {
62
+ private audioContext;
63
+ private cache;
64
+ constructor();
65
+ /**
66
+ * Creates an AudioPlayer from a URL.
67
+ * It fetches, decodes, and caches the audio data. If the URL is already cached,
68
+ * it skips the network request and uses the cached data.
69
+ *
70
+ * @param url - The URL of the audio file.
71
+ * @returns A Promise that resolves to a new AudioPlayer instance.
72
+ */
73
+ audioFromUrl(url: string): Promise<AudioPlayer>;
74
+ /**
75
+ * Destroys the AudioManager, clears the audio cache, and closes the AudioContext.
76
+ * This releases all associated audio resources. After calling this, the AudioManager
77
+ * and any AudioPlayers created by it will be unusable.
78
+ */
79
+ destroy(): void;
80
+ }
81
+ export default AudioManager;
package/dist/game.d.ts ADDED
@@ -0,0 +1,324 @@
1
+ import { default as AssetsLoader } from './assets';
2
+ import { default as AudioManager } from './audio';
3
+ import { InputManager } from './input';
4
+ import { IAnimation, ICameraOptions, IEntityTransformOptions, IGameOptions, ILabelEntityOptions, IMathObject, ISpriteOptions } from './interface';
5
+ import { Color, MatrixStack, Vec2 } from './math';
6
+ import { default as Rapid } from './render';
7
+ import { Text, Texture, TextureCache } from './texture';
8
+ import { EasingFunction, Timer, Tween } from './utils';
9
+ /**
10
+ * Base class for game entities with transform and rendering capabilities.
11
+ */
12
+ export declare class Entity {
13
+ position: Vec2;
14
+ scale: Vec2;
15
+ rotation: number;
16
+ parent: Entity | null;
17
+ globalZindex: number;
18
+ localZindex: number;
19
+ tags: string[];
20
+ transform: MatrixStack;
21
+ readonly children: Entity[];
22
+ protected rapid: Rapid;
23
+ protected game: Game;
24
+ get x(): number;
25
+ get y(): number;
26
+ set x(nx: number);
27
+ set y(ny: number);
28
+ /**
29
+ * Creates an entity with optional transform properties.
30
+ * @param game - The game instance this entity belongs to.
31
+ * @param options - Configuration options for position, scale, rotation, and tags.
32
+ */
33
+ constructor(game: Game, options?: IEntityTransformOptions);
34
+ getScene(): Scene | null;
35
+ /**
36
+ * Gets the parent transform or the renderer's matrix stack if no parent exists.
37
+ * @returns The transform matrix stack.
38
+ */
39
+ getParentTransform(): MatrixStack;
40
+ /**
41
+ * Updates the entity and its children.
42
+ * @param deltaTime - Time elapsed since the last update in seconds.
43
+ */
44
+ update(deltaTime: number): void;
45
+ /**
46
+ * Hook for custom update logic.
47
+ * @param deltaTime - Time elapsed since the last update in seconds.
48
+ */
49
+ protected onUpdate(deltaTime: number): void;
50
+ /**
51
+ * Collects entities that need rendering.
52
+ * @param queue - The array to collect renderable entities.
53
+ * @ignore
54
+ */
55
+ collectRenderables(queue: Entity[]): void;
56
+ /**
57
+ * Prepares the entity's transform before rendering.
58
+ * @ignore
59
+ */
60
+ beforeOnRender(): void;
61
+ /**
62
+ * Hook for custom rendering logic.
63
+ * @param render - The rendering engine instance.
64
+ */
65
+ onRender(render: Rapid): void;
66
+ /**
67
+ * Updates the entity's transform, optionally updating parent transforms.
68
+ * @param deep - If true, recursively updates parent transforms.
69
+ */
70
+ updateTransform(deep?: boolean): void;
71
+ /**
72
+ * Adds a child entity to this entity.
73
+ * @param child - The entity to add as a child.
74
+ */
75
+ addChild(child: Entity): void;
76
+ /**
77
+ * Removes a child entity from this entity.
78
+ * @param child - The entity to remove.
79
+ */
80
+ removeChild(child: Entity): void;
81
+ /**
82
+ * Finds descendant entities matching a predicate.
83
+ * @param predicate - Function to test each entity.
84
+ * @param onlyFirst - If true, returns only the first match; otherwise, returns all matches.
85
+ * @returns A single entity, an array of entities, or null if no matches are found.
86
+ */
87
+ findDescendant(predicate: (entity: Entity) => boolean, onlyFirst?: boolean): Entity[] | Entity | null;
88
+ /**
89
+ * Finds descendant entities with all specified tags.
90
+ * @param tags - Array of tags to match.
91
+ * @param onlyFirst - If true, returns only the first match; otherwise, returns all matches.
92
+ * @returns A single entity, an array of entities, or null if no matches are found.
93
+ */
94
+ findDescendantByTag(tags: string[], onlyFirst?: boolean): Entity[] | Entity | null;
95
+ /**
96
+ * Disposes of the entity and its children.
97
+ */
98
+ dispose(): void;
99
+ /**
100
+ * Hook for custom cleanup logic before disposal.
101
+ */
102
+ protected postDispose(): void;
103
+ getMouseLocalPosition(): Vec2;
104
+ getMouseGlobalPosition(): Vec2;
105
+ }
106
+ /**
107
+ * A layer that renders its children directly to the screen, ignoring any camera transforms.
108
+ * Ideal for UI elements like HUDs, menus, and scores.
109
+ *
110
+ * CanvasLayer 是一个特殊的层,它会直接将其子节点渲染到屏幕上,忽略任何摄像机的变换。
111
+ * 非常适合用于UI元素,如HUD(状态栏)、菜单和分数显示。
112
+ */
113
+ export declare class CanvasLayer extends Entity {
114
+ constructor(game: Game, options: IEntityTransformOptions);
115
+ updateTransform(): void;
116
+ }
117
+ /**
118
+ * Camera entity for managing the view transform in the game.
119
+ */
120
+ export declare class Camera extends Entity {
121
+ enable: boolean;
122
+ center: boolean;
123
+ positionSmoothingSpeed: number;
124
+ rotationSmoothingSpeed: number;
125
+ private _currentRenderPosition;
126
+ private _currentRenderRotation;
127
+ /**
128
+ * 设置此摄像机是否为当前场景的主摄像机。
129
+ * @param isEnable
130
+ */
131
+ setEnable(isEnable: boolean): void;
132
+ constructor(game: Game, options?: ICameraOptions);
133
+ /**
134
+ * 每帧更新,用于平滑摄像机的【局部】变换属性。
135
+ * @param deltaTime
136
+ */
137
+ onUpdate(deltaTime: number): void;
138
+ /**
139
+ * 根据摄像机的【全局】变换计算最终的视图矩阵。
140
+ * 这个方法现在正确地处理了父子关系。
141
+ */
142
+ updateTransform(): void;
143
+ }
144
+ /**
145
+ * Scene class representing a game scene with entities.
146
+ */
147
+ export declare class Scene extends Entity {
148
+ /**
149
+ * Initializes the scene.
150
+ */
151
+ create(): void;
152
+ }
153
+ /**
154
+ * Main game class managing the game loop, rendering, and input.
155
+ */
156
+ export declare class Game {
157
+ render: Rapid;
158
+ mainScene: Scene | null;
159
+ input: InputManager;
160
+ asset: AssetsLoader;
161
+ audio: AudioManager;
162
+ texture: TextureCache;
163
+ private isRunning;
164
+ private lastTime;
165
+ private tweens;
166
+ private timers;
167
+ mainCamera: Camera | null;
168
+ renderQueue: Entity[];
169
+ worldTransform: MatrixStack;
170
+ /**
171
+ * Creates a new game instance.
172
+ * @param options - Configuration options for the game.
173
+ */
174
+ constructor(options: IGameOptions);
175
+ getMainScene(): Scene | null;
176
+ setMainCamera(camera: Camera | null): void;
177
+ /**
178
+ * Switches to a new scene, disposing of the current one.
179
+ * @param newScene - The new scene to switch to.
180
+ */
181
+ switchScene(newScene: Scene): void;
182
+ /**
183
+ * Starts the game loop.
184
+ */
185
+ start(): void;
186
+ /**
187
+ * Stops the game loop.
188
+ */
189
+ stop(): void;
190
+ /**
191
+ * Adds an entity to the render queue.
192
+ * @param entity - The entity to add.
193
+ */
194
+ addEntityRenderQueue(entity: Entity): void;
195
+ /**
196
+ * Runs the game loop, updating and rendering the scene.
197
+ * @private
198
+ */
199
+ private gameLoop;
200
+ destroy(): void;
201
+ /**
202
+ * Creates and starts a new timer that will be automatically updated by the game loop.
203
+ * @param duration - The duration in seconds before the timer triggers.
204
+ * @param onComplete - The function to call when the timer finishes.
205
+ * @param repeat - If true, the timer will restart after completing. Defaults to false.
206
+ * @returns The created Timer instance, allowing you to `stop()` it manually if needed.
207
+ * @example
208
+ * // Log a message after 2.5 seconds
209
+ * game.createTimer(2.5, () => {
210
+ * console.log('Timer finished!');
211
+ * });
212
+ *
213
+ * // Spawn an enemy every 5 seconds
214
+ * const enemySpawner = game.createTimer(5, () => {
215
+ * scene.spawnEnemy();
216
+ * }, true);
217
+ */
218
+ createTimer(duration: number, repeat?: boolean): Timer;
219
+ /**
220
+ * Updates all active timers and removes completed ones.
221
+ * @param deltaTime - The time elapsed since the last frame.
222
+ * @private
223
+ */
224
+ private updateTimers;
225
+ /**
226
+ * Creates and starts a new tween animation.
227
+ * The tween will be automatically updated by the game loop.
228
+ * @template T - The type of the value being animated (e.g., Vec2, Color, number).
229
+ * @param target - The object to animate.
230
+ * @param property - The name of the property on the target to animate.
231
+ * @param to - The final value of the property.
232
+ * @param duration - The duration of the animation in seconds.
233
+ * @param easing - The easing function to use. Defaults to Linear.
234
+ * @returns The created Tween instance, allowing you to chain calls like .onComplete().
235
+ * @example
236
+ * // Tween a sprite's position over 2 seconds
237
+ * game.createTween(mySprite, 'position', new Vec2(500, 300), 2, Easing.EaseOutQuad);
238
+ *
239
+ * // Tween a shape's color to red and do something on completion
240
+ * game.createTween(myShape, 'color', Color.Red, 1.5)
241
+ * .onComplete(() => {
242
+ * console.log('Color tween finished!');
243
+ * });
244
+ */
245
+ createTween<T extends IMathObject<T> | number>(target: any, property: string, to: T, duration: number, easing?: EasingFunction): Tween<T>;
246
+ /**
247
+ * Updates all active tweens and removes completed ones.
248
+ * @param deltaTime - The time elapsed since the last frame.
249
+ * @private
250
+ */
251
+ private updateTweens;
252
+ }
253
+ /**
254
+ * An entity that displays a texture (a "sprite") and can play animations.
255
+ * Animations are defined as a sequence of textures.
256
+ */
257
+ export declare class Sprite extends Entity {
258
+ /** The current texture being displayed. This can be a static texture or a frame from an animation. */
259
+ texture: Texture | null;
260
+ /** Whether the sprite is flipped horizontally. */
261
+ flipX: boolean;
262
+ /** Whether the sprite is flipped vertically. */
263
+ flipY: boolean;
264
+ color: Color;
265
+ offset: Vec2;
266
+ private animations;
267
+ private currentAnimation;
268
+ private currentFrame;
269
+ private frameTimer;
270
+ private isPlaying;
271
+ /**
272
+ * Creates a new Sprite entity.
273
+ * @param game - The game instance.
274
+ * @param options - Configuration for the sprite's transform and initial texture.
275
+ */
276
+ constructor(game: Game, options?: ISpriteOptions);
277
+ setAnimations(animations: IAnimation): void;
278
+ /**
279
+ * Defines a new animation sequence.
280
+ * @param name - A unique name for the animation (e.g., "walk", "jump").
281
+ * @param frames - An array of Textures to use as frames.
282
+ * @param fps - The playback speed in frames per second.
283
+ * @param loop - Whether the animation should repeat.
284
+ */
285
+ addAnimation(name: string, frames: Texture[], fps?: number, loop?: boolean): void;
286
+ /**
287
+ * Plays an animation that has been previously defined with `addAnimation`.
288
+ * @param name - The name of the animation to play.
289
+ * @param forceRestart - If true, the animation will restart from the first frame even if it's already playing.
290
+ */
291
+ play(name: string, forceRestart?: boolean): void;
292
+ /**
293
+ * Stops the currently playing animation.
294
+ * The sprite will remain on the current frame.
295
+ */
296
+ stop(): void;
297
+ /**
298
+ * Updates the animation frame based on the elapsed time.
299
+ * @param deltaTime - Time in seconds since the last frame.
300
+ * @override
301
+ */
302
+ onUpdate(deltaTime: number): void;
303
+ /**
304
+ * Renders the sprite's current texture to the screen.
305
+ * @param render - The Rapid rendering instance.
306
+ * @override
307
+ */
308
+ onRender(render: Rapid): void;
309
+ }
310
+ /**
311
+ * An entity designed specifically to display text on the screen.
312
+ * It encapsulates a `Text` texture, giving it position, scale, rotation,
313
+ * and other entity-based properties.
314
+ */
315
+ export declare class Label extends Entity {
316
+ text: Text;
317
+ constructor(game: Game, options: ILabelEntityOptions);
318
+ onRender(render: Rapid): void;
319
+ /**
320
+ * Updates the displayed text. Re-renders the texture if the text has changed.
321
+ * @param text - The new text to display.
322
+ */
323
+ setText(text: string): void;
324
+ }