rapid-render 0.1.2-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/dist/assets.d.ts +9 -8
- package/dist/audio.d.ts +49 -27
- package/dist/game.d.ts +113 -81
- package/dist/index.d.ts +15 -15
- package/dist/input.d.ts +6 -4
- package/dist/interface.d.ts +29 -13
- package/dist/light.d.ts +2 -2
- package/dist/line.d.ts +2 -2
- package/dist/math.d.ts +10 -3
- package/dist/particle.d.ts +16 -13
- package/dist/rapid.global.js +1 -1
- package/dist/rapid.js +4814 -1
- package/dist/rapid.umd.cjs +1 -1
- package/dist/render.d.ts +8 -11
- package/dist/texture.d.ts +14 -18
- package/dist/tilemap.d.ts +83 -22
- package/dist/utils.d.ts +1 -1
- package/package.json +9 -7
- package/dist/depth.d.ts +0 -8
- package/dist/regions/attributes.d.ts +0 -44
- package/dist/regions/graphic_region.d.ts +0 -15
- package/dist/regions/region.d.ts +0 -41
- package/dist/regions/sprite_region.d.ts +0 -18
- package/dist/webgl/glshader.d.ts +0 -38
- package/dist/webgl/uniform.d.ts +0 -14
- package/dist/webgl/utils.d.ts +0 -37
package/dist/assets.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AudioPlayer } from
|
|
2
|
-
import { Game } from
|
|
3
|
-
import { IAsset
|
|
4
|
-
import EventEmitter from
|
|
1
|
+
import { AudioPlayer } from './audio';
|
|
2
|
+
import { Game } from './game';
|
|
3
|
+
import { IAsset, IAssets } from './interface';
|
|
4
|
+
import { default as EventEmitter } from 'eventemitter3';
|
|
5
5
|
/**
|
|
6
6
|
* Events emitted by AssetsLoader.
|
|
7
7
|
*/
|
|
@@ -35,17 +35,18 @@ declare class AssetsLoader extends EventEmitter<AssetsLoaderEvents> {
|
|
|
35
35
|
*/
|
|
36
36
|
loadJson(name: string, url: string): void;
|
|
37
37
|
/**
|
|
38
|
-
* Loads an audio file asynchronously.
|
|
38
|
+
* Loads an audio file asynchronously using the AudioManager.
|
|
39
|
+
* The AudioManager will handle fetching and caching.
|
|
39
40
|
* @param name - The unique identifier for the audio asset.
|
|
40
41
|
* @param url - The URL of the audio file.
|
|
41
42
|
*/
|
|
42
|
-
loadAudio(name: string, url: string): void
|
|
43
|
+
loadAudio(name: string, url: string): Promise<void>;
|
|
43
44
|
/**
|
|
44
|
-
* Loads an image file asynchronously.
|
|
45
|
+
* Loads an image file asynchronously using the TextureManager.
|
|
45
46
|
* @param name - The unique identifier for the image asset.
|
|
46
47
|
* @param url - The URL of the image file.
|
|
47
48
|
*/
|
|
48
|
-
loadImage(name: string, url: string): void
|
|
49
|
+
loadImage(name: string, url: string): Promise<void>;
|
|
49
50
|
/**
|
|
50
51
|
* Loads multiple assets from a list.
|
|
51
52
|
* @param assetList - Array of assets to load.
|
package/dist/audio.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import EventEmitter from
|
|
1
|
+
import { default as EventEmitter } from 'eventemitter3';
|
|
2
2
|
/**
|
|
3
3
|
* Events emitted by AudioPlayer.
|
|
4
4
|
*/
|
|
@@ -6,54 +6,76 @@ interface AudioPlayerEvents {
|
|
|
6
6
|
ended: () => void;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Represents a single, playable audio instance.
|
|
10
|
+
* Created by the AudioManager.
|
|
11
11
|
*/
|
|
12
12
|
export declare class AudioPlayer extends EventEmitter<AudioPlayerEvents> {
|
|
13
|
-
element: HTMLAudioElement;
|
|
14
|
-
source: AudioNode | null;
|
|
15
|
-
gainNode: GainNode;
|
|
16
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);
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param audioElement - The HTMLAudioElement to manage.
|
|
20
|
-
* @param audioContext - The Web Audio API context.
|
|
22
|
+
* Plays the audio. If already playing, it will stop the current playback and start over.
|
|
21
23
|
*/
|
|
22
|
-
|
|
24
|
+
play(): void;
|
|
23
25
|
/**
|
|
24
|
-
*
|
|
26
|
+
* Stops the audio playback immediately.
|
|
25
27
|
*/
|
|
26
|
-
|
|
28
|
+
stop(): void;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param loop - Whether the audio should loop (default: false).
|
|
30
|
+
* Gets the volume of the audio, from 0.0 to 1.0.
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
get volume(): number;
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
+
* Sets the volume of the audio.
|
|
35
|
+
* @param value - The volume, from 0.0 (silent) to 1.0 (full).
|
|
34
36
|
*/
|
|
35
|
-
|
|
37
|
+
set volume(value: number);
|
|
36
38
|
/**
|
|
37
|
-
*
|
|
39
|
+
* Gets whether the audio will loop.
|
|
38
40
|
*/
|
|
39
|
-
|
|
41
|
+
get loop(): boolean;
|
|
40
42
|
/**
|
|
41
|
-
* Sets the
|
|
42
|
-
*
|
|
43
|
+
* Sets whether the audio should loop.
|
|
44
|
+
* Can be changed while the audio is playing.
|
|
43
45
|
*/
|
|
44
|
-
|
|
46
|
+
set loop(value: boolean);
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
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.
|
|
47
54
|
*/
|
|
48
55
|
destroy(): void;
|
|
49
56
|
}
|
|
50
57
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
58
|
+
* Manages loading, decoding, and caching of audio assets.
|
|
59
|
+
* This is analogous to your TextureCache.
|
|
53
60
|
*/
|
|
54
|
-
declare class AudioManager {
|
|
55
|
-
audioContext
|
|
61
|
+
export declare class AudioManager {
|
|
62
|
+
private audioContext;
|
|
63
|
+
private cache;
|
|
56
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
|
+
*/
|
|
57
79
|
destroy(): void;
|
|
58
80
|
}
|
|
59
81
|
export default AudioManager;
|
package/dist/game.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import AssetsLoader from
|
|
2
|
-
import AudioManager from
|
|
3
|
-
import { InputManager } from
|
|
4
|
-
import {
|
|
5
|
-
import { MatrixStack, Vec2 } from
|
|
6
|
-
import Rapid from
|
|
7
|
-
import { TextureCache } from
|
|
8
|
-
import {
|
|
9
|
-
import { EasingFunction, Timer, Tween } from "./utils";
|
|
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';
|
|
10
9
|
/**
|
|
11
10
|
* Base class for game entities with transform and rendering capabilities.
|
|
12
11
|
*/
|
|
@@ -32,6 +31,7 @@ export declare class Entity {
|
|
|
32
31
|
* @param options - Configuration options for position, scale, rotation, and tags.
|
|
33
32
|
*/
|
|
34
33
|
constructor(game: Game, options?: IEntityTransformOptions);
|
|
34
|
+
getScene(): Scene | null;
|
|
35
35
|
/**
|
|
36
36
|
* Gets the parent transform or the renderer's matrix stack if no parent exists.
|
|
37
37
|
* @returns The transform matrix stack.
|
|
@@ -57,7 +57,7 @@ export declare class Entity {
|
|
|
57
57
|
* Prepares the entity's transform before rendering.
|
|
58
58
|
* @ignore
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
beforeOnRender(): void;
|
|
61
61
|
/**
|
|
62
62
|
* Hook for custom rendering logic.
|
|
63
63
|
* @param render - The rendering engine instance.
|
|
@@ -100,90 +100,46 @@ export declare class Entity {
|
|
|
100
100
|
* Hook for custom cleanup logic before disposal.
|
|
101
101
|
*/
|
|
102
102
|
protected postDispose(): void;
|
|
103
|
+
getMouseLocalPosition(): Vec2;
|
|
104
|
+
getMouseGlobalPosition(): Vec2;
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
105
|
-
*
|
|
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(状态栏)、菜单和分数显示。
|
|
106
112
|
*/
|
|
107
|
-
export declare class
|
|
108
|
-
|
|
109
|
-
* Updates the camera's transform to center the view and apply transformations.
|
|
110
|
-
*/
|
|
113
|
+
export declare class CanvasLayer extends Entity {
|
|
114
|
+
constructor(game: Game, options: IEntityTransformOptions);
|
|
111
115
|
updateTransform(): void;
|
|
112
116
|
}
|
|
113
117
|
/**
|
|
114
|
-
*
|
|
118
|
+
* Camera entity for managing the view transform in the game.
|
|
115
119
|
*/
|
|
116
|
-
export declare class
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
eachTile?: (tileId: string | number, mapX: number, mapY: number) => ISpriteRenderOptions | undefined | void;
|
|
124
|
-
ySortCallback: YSortCallback[];
|
|
125
|
-
/**
|
|
126
|
-
* Creates a tilemap entity.
|
|
127
|
-
* @param game - The game instance this tilemap belongs to.
|
|
128
|
-
* @param options - Configuration options for the tilemap.
|
|
129
|
-
*/
|
|
130
|
-
constructor(game: Game, options: IEntityTilemapLayerOptions);
|
|
131
|
-
/**
|
|
132
|
-
* Collects renderable entities, excluding children unless they override onRender.
|
|
133
|
-
* @param queue - The array to collect renderable entities.
|
|
134
|
-
*/
|
|
135
|
-
collectRenderables(queue: Entity[]): void;
|
|
136
|
-
/**
|
|
137
|
-
* Sets a tile at the specified map coordinates.
|
|
138
|
-
* @param x - The X coordinate (column) on the map.
|
|
139
|
-
* @param y - The Y coordinate (row) on the map.
|
|
140
|
-
* @param tileId - The tile ID to set (number or string).
|
|
141
|
-
* @returns True if the tile was set successfully, false if coordinates are out of bounds.
|
|
142
|
-
*/
|
|
143
|
-
setTile(x: number, y: number, tileId: number | string): boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Gets the tile ID at the specified map coordinates.
|
|
146
|
-
* @param x - The X coordinate (column) on the map.
|
|
147
|
-
* @param y - The Y coordinate (row) on the map.
|
|
148
|
-
* @returns The tile ID (number or string) or undefined if coordinates are out of bounds.
|
|
149
|
-
*/
|
|
150
|
-
getTile(x: number, y: number): number | string | undefined;
|
|
151
|
-
/**
|
|
152
|
-
* Removes a tile at the specified map coordinates (sets it to EMPTY_TILE).
|
|
153
|
-
* @param x - The X coordinate (column) on the map.
|
|
154
|
-
* @param y - The Y coordinate (row) on the map.
|
|
155
|
-
* @returns True if the tile was removed successfully, false if coordinates are out of bounds.
|
|
156
|
-
*/
|
|
157
|
-
removeTile(x: number, y: number): boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Fills a rectangular area with a specified tile ID.
|
|
160
|
-
* @param tileId - The tile ID to use for filling.
|
|
161
|
-
* @param startX - The starting X coordinate.
|
|
162
|
-
* @param startY - The starting Y coordinate.
|
|
163
|
-
* @param width - The width of the fill area.
|
|
164
|
-
* @param height - The height of the fill area.
|
|
165
|
-
*/
|
|
166
|
-
fill(tileId: number | string, startX: number, startY: number, width: number, height: number): void;
|
|
167
|
-
/**
|
|
168
|
-
* Replaces the entire tilemap data and updates dimensions.
|
|
169
|
-
* @param newData - The new 2D array of tile data.
|
|
170
|
-
*/
|
|
171
|
-
setData(newData: (number | string)[][]): void;
|
|
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;
|
|
172
127
|
/**
|
|
173
|
-
*
|
|
174
|
-
* @param
|
|
128
|
+
* 设置此摄像机是否为当前场景的主摄像机。
|
|
129
|
+
* @param isEnable
|
|
175
130
|
*/
|
|
176
|
-
|
|
131
|
+
setEnable(isEnable: boolean): void;
|
|
132
|
+
constructor(game: Game, options?: ICameraOptions);
|
|
177
133
|
/**
|
|
178
|
-
*
|
|
179
|
-
* @param
|
|
134
|
+
* 每帧更新,用于平滑摄像机的【局部】变换属性。
|
|
135
|
+
* @param deltaTime
|
|
180
136
|
*/
|
|
181
|
-
|
|
137
|
+
onUpdate(deltaTime: number): void;
|
|
182
138
|
/**
|
|
183
|
-
*
|
|
184
|
-
*
|
|
139
|
+
* 根据摄像机的【全局】变换计算最终的视图矩阵。
|
|
140
|
+
* 这个方法现在正确地处理了父子关系。
|
|
185
141
|
*/
|
|
186
|
-
|
|
142
|
+
updateTransform(): void;
|
|
187
143
|
}
|
|
188
144
|
/**
|
|
189
145
|
* Scene class representing a game scene with entities.
|
|
@@ -208,12 +164,16 @@ export declare class Game {
|
|
|
208
164
|
private lastTime;
|
|
209
165
|
private tweens;
|
|
210
166
|
private timers;
|
|
167
|
+
mainCamera: Camera | null;
|
|
211
168
|
renderQueue: Entity[];
|
|
169
|
+
worldTransform: MatrixStack;
|
|
212
170
|
/**
|
|
213
171
|
* Creates a new game instance.
|
|
214
172
|
* @param options - Configuration options for the game.
|
|
215
173
|
*/
|
|
216
174
|
constructor(options: IGameOptions);
|
|
175
|
+
getMainScene(): Scene | null;
|
|
176
|
+
setMainCamera(camera: Camera | null): void;
|
|
217
177
|
/**
|
|
218
178
|
* Switches to a new scene, disposing of the current one.
|
|
219
179
|
* @param newScene - The new scene to switch to.
|
|
@@ -290,3 +250,75 @@ export declare class Game {
|
|
|
290
250
|
*/
|
|
291
251
|
private updateTweens;
|
|
292
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
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import Rapid from
|
|
2
|
-
import GLShader from
|
|
3
|
-
import { Text } from
|
|
4
|
-
import { TileMapRender, TileSet } from
|
|
5
|
-
import { Uniform } from
|
|
6
|
-
import { spriteAttributes, graphicAttributes } from
|
|
7
|
-
import { ParticleEmitter } from
|
|
1
|
+
import { default as Rapid } from './render';
|
|
2
|
+
import { default as GLShader } from './webgl/glshader';
|
|
3
|
+
import { Text } from './texture';
|
|
4
|
+
import { TileMapRender, TileSet } from './tilemap';
|
|
5
|
+
import { Uniform } from './webgl/uniform';
|
|
6
|
+
import { spriteAttributes, graphicAttributes } from './regions/attributes';
|
|
7
|
+
import { ParticleEmitter } from './particle';
|
|
8
8
|
export { Text, Rapid, GLShader, TileMapRender, TileSet, Uniform, ParticleEmitter, graphicAttributes, spriteAttributes, };
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
9
|
+
export * from './math';
|
|
10
|
+
export * from './interface';
|
|
11
|
+
export * from './texture';
|
|
12
|
+
export * from './render';
|
|
13
|
+
export * from './particle';
|
|
14
|
+
export * from './game';
|
|
15
|
+
export * from './input';
|
|
16
|
+
export * from './assets';
|
package/dist/input.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Vec2 } from
|
|
2
|
-
import Rapid from
|
|
3
|
-
import { Entity } from
|
|
1
|
+
import { Vec2 } from './math';
|
|
2
|
+
import { default as Rapid } from './render';
|
|
3
|
+
import { Entity } from './game';
|
|
4
4
|
/**
|
|
5
5
|
* Manages user input for keyboard and mouse events.
|
|
6
6
|
* Tracks key and button states, including pressed/released states for the current and previous frames.
|
|
@@ -8,7 +8,7 @@ import { Entity } from "./game";
|
|
|
8
8
|
export declare class InputManager {
|
|
9
9
|
private rapid;
|
|
10
10
|
private canvas;
|
|
11
|
-
|
|
11
|
+
mousePosition: Vec2;
|
|
12
12
|
private keysDown;
|
|
13
13
|
private keysDownLastFrame;
|
|
14
14
|
private buttonsDown;
|
|
@@ -81,6 +81,8 @@ export declare class InputManager {
|
|
|
81
81
|
* @returns The mouse position in the entity's local coordinate system.
|
|
82
82
|
*/
|
|
83
83
|
getMouseLocal(entity: Entity): Vec2;
|
|
84
|
+
getAxis(negativeAction: string, positiveAction: string): number;
|
|
85
|
+
getVector(negativeX: string, positiveX: string, negativeY: string, positiveY: string): Vec2;
|
|
84
86
|
/**
|
|
85
87
|
* Removes all event listeners and cleans up resources.
|
|
86
88
|
*/
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AudioPlayer } from
|
|
2
|
-
import { Entity } from
|
|
3
|
-
import { Color, Vec2 } from
|
|
4
|
-
import { Texture } from
|
|
5
|
-
import { TileSet } from
|
|
6
|
-
import GLShader from
|
|
7
|
-
import { Uniform } from
|
|
1
|
+
import { AudioPlayer } from './audio';
|
|
2
|
+
import { Entity } from './game';
|
|
3
|
+
import { Color, Vec2 } from './math';
|
|
4
|
+
import { Texture } from './texture';
|
|
5
|
+
import { TileSet } from './tilemap';
|
|
6
|
+
import { default as GLShader } from './webgl/glshader';
|
|
7
|
+
import { Uniform } from './webgl/uniform';
|
|
8
8
|
/**
|
|
9
9
|
* @ignore
|
|
10
10
|
*/
|
|
@@ -114,7 +114,7 @@ export interface ITextTextureOptions {
|
|
|
114
114
|
* The color of the text.
|
|
115
115
|
* Default is '#000000' (black).
|
|
116
116
|
*/
|
|
117
|
-
color?:
|
|
117
|
+
color?: Color;
|
|
118
118
|
/**
|
|
119
119
|
* The alignment of the text.
|
|
120
120
|
* Possible values: 'left', 'right', 'center', 'start', 'end'.
|
|
@@ -182,6 +182,7 @@ export interface YSortCallback {
|
|
|
182
182
|
renderSprite?: ISpriteRenderOptions;
|
|
183
183
|
}
|
|
184
184
|
export interface IEntityTilemapLayerOptions extends ITilemapLayerOptions, IEntityTransformOptions {
|
|
185
|
+
enableYsort: boolean;
|
|
185
186
|
}
|
|
186
187
|
export interface ITilemapLayerOptions {
|
|
187
188
|
error?: number | Vec2;
|
|
@@ -226,6 +227,9 @@ export interface ILightRenderOptions {
|
|
|
226
227
|
}
|
|
227
228
|
export interface ICameraOptions extends ITransformOptions {
|
|
228
229
|
center?: boolean;
|
|
230
|
+
enable?: boolean;
|
|
231
|
+
positionSmoothingSpeed?: number;
|
|
232
|
+
rotationSmoothingSpeed?: number;
|
|
229
233
|
}
|
|
230
234
|
/**
|
|
231
235
|
* Defines particle emitter shape types
|
|
@@ -362,12 +366,9 @@ export type ParticleAttributeData<T extends ParticleAttributeTypes> = {
|
|
|
362
366
|
*/
|
|
363
367
|
damping?: number;
|
|
364
368
|
};
|
|
365
|
-
export interface
|
|
369
|
+
export interface IParticleEmitterOptions extends IParticleOptions, IEntityTransformOptions {
|
|
366
370
|
}
|
|
367
|
-
export interface
|
|
368
|
-
element: HTMLAudioElement;
|
|
369
|
-
source: MediaElementAudioSourceNode | null;
|
|
370
|
-
gainNode: GainNode;
|
|
371
|
+
export interface IGameOptions extends IRapidOptions {
|
|
371
372
|
}
|
|
372
373
|
/**
|
|
373
374
|
* Interface for an asset to be loaded.
|
|
@@ -391,3 +392,18 @@ export interface IAssets {
|
|
|
391
392
|
[key: string]: Texture;
|
|
392
393
|
};
|
|
393
394
|
}
|
|
395
|
+
export interface IAnimation {
|
|
396
|
+
/** The name of the animation, used to play it. */
|
|
397
|
+
name: string;
|
|
398
|
+
/** An array of Textures that make up the frames of the animation. */
|
|
399
|
+
frames: Texture[];
|
|
400
|
+
/** The speed of the animation in frames per second (FPS). */
|
|
401
|
+
fps: number;
|
|
402
|
+
/** Whether the animation should loop back to the first frame when it ends. */
|
|
403
|
+
loop: boolean;
|
|
404
|
+
}
|
|
405
|
+
export interface ISpriteOptions extends IEntityTransformOptions, ISpriteRenderOptions {
|
|
406
|
+
animations?: IAnimation;
|
|
407
|
+
}
|
|
408
|
+
export interface ILabelEntityOptions extends ITextTextureOptions, IEntityTransformOptions {
|
|
409
|
+
}
|
package/dist/light.d.ts
CHANGED
package/dist/line.d.ts
CHANGED
package/dist/math.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMathObject, ITransformOptions, WebGLContext } from
|
|
1
|
+
import { IMathObject, ITransformOptions, WebGLContext } from './interface';
|
|
2
2
|
/**
|
|
3
3
|
* @ignore
|
|
4
4
|
*/
|
|
@@ -21,7 +21,7 @@ export declare class DynamicArrayBuffer {
|
|
|
21
21
|
private float32?;
|
|
22
22
|
private uint16?;
|
|
23
23
|
constructor(arrayType: ArrayType);
|
|
24
|
-
getArrayType(arrayType: ArrayType):
|
|
24
|
+
getArrayType(arrayType: ArrayType): Float32ArrayConstructor | Uint32ArrayConstructor | Uint16ArrayConstructor;
|
|
25
25
|
updateTypedArray(): void;
|
|
26
26
|
clear(): void;
|
|
27
27
|
/**
|
|
@@ -45,7 +45,7 @@ export declare class DynamicArrayBuffer {
|
|
|
45
45
|
* @param end
|
|
46
46
|
* @returns
|
|
47
47
|
*/
|
|
48
|
-
getArray(begin?: number, end?: number):
|
|
48
|
+
getArray(begin?: number, end?: number): Uint32Array | Float32Array | Uint16Array;
|
|
49
49
|
/**
|
|
50
50
|
* length of the array
|
|
51
51
|
*/
|
|
@@ -265,6 +265,12 @@ export declare class Color implements IMathObject<Color> {
|
|
|
265
265
|
* @returns A new `Color` instance with the same RGBA values.
|
|
266
266
|
*/
|
|
267
267
|
clone(): Color;
|
|
268
|
+
/**
|
|
269
|
+
* Converts the color to a hexadecimal string representation (e.g., '#RRGGBBAA').
|
|
270
|
+
* @param includeAlpha - Whether to include the alpha channel in the hex string.
|
|
271
|
+
* @returns The hexadecimal string representation of the color.
|
|
272
|
+
*/
|
|
273
|
+
toHexString(includeAlpha?: boolean): string;
|
|
268
274
|
/**
|
|
269
275
|
* Checks if the current color is equal to another color.
|
|
270
276
|
* @param color - The color to compare with.
|
|
@@ -455,6 +461,7 @@ export declare class Vec2 implements IMathObject<Vec2> {
|
|
|
455
461
|
* @returns The angle between the two vectors in radians.
|
|
456
462
|
*/
|
|
457
463
|
angleBetween(v: Vec2): number;
|
|
464
|
+
lerp(target: Vec2, factor: number): Vec2;
|
|
458
465
|
}
|
|
459
466
|
/**
|
|
460
467
|
* Provides utility methods for mathematical conversions.
|