Skip to content

Commit 9e19965

Browse files
committed
vite
1 parent 2576099 commit 9e19965

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6011
-5553
lines changed

dist/assets.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { AudioPlayer } from "./audio";
2-
import { Game } from "./game";
3-
import { IAsset as IAsset, IAssets } from "./interface";
4-
import EventEmitter from "eventemitter3";
1+
import { AudioPlayer } from './audio';
2+
import { Game } from './game';
3+
import { IAsset as IAsset, IAssets } from './interface';
4+
import { default as EventEmitter } from 'eventemitter3';
55
/**
66
* Events emitted by AssetsLoader.
77
*/

dist/audio.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import EventEmitter from "eventemitter3";
1+
import { default as EventEmitter } from 'eventemitter3';
22
/**
33
* Events emitted by AudioPlayer.
44
*/

dist/depth.d.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

dist/game.d.ts

Lines changed: 38 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import AssetsLoader from "./assets";
2-
import AudioManager from "./audio";
3-
import { InputManager } from "./input";
4-
import { IEntityTilemapLayerOptions, IEntityTransformOptions, IGameOptions, IMathObject, ISpriteRenderOptions, TilemapShape, YSortCallback } from "./interface";
5-
import { MatrixStack, Vec2 } from "./math";
6-
import Rapid from "./render";
7-
import { TextureCache } from "./texture";
8-
import { TileSet } from "./tilemap";
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 { ICameraOptions, IEntityTransformOptions, IGameOptions, IMathObject } from './interface';
5+
import { MatrixStack, Vec2 } from './math';
6+
import { default as Rapid } from './render';
7+
import { TextureCache } from './texture';
8+
import { EasingFunction, Timer, Tween } from './utils';
109
/**
1110
* Base class for game entities with transform and rendering capabilities.
1211
*/
@@ -32,6 +31,7 @@ export declare class Entity {
3231
* @param options - Configuration options for position, scale, rotation, and tags.
3332
*/
3433
constructor(game: Game, options?: IEntityTransformOptions);
34+
getRoot(): Scene | null;
3535
/**
3636
* Gets the parent transform or the renderer's matrix stack if no parent exists.
3737
* @returns The transform matrix stack.
@@ -57,7 +57,7 @@ export declare class Entity {
5757
* Prepares the entity's transform before rendering.
5858
* @ignore
5959
*/
60-
beforOnRender(): void;
60+
beforeOnRender(): void;
6161
/**
6262
* Hook for custom rendering logic.
6363
* @param render - The rendering engine instance.
@@ -102,88 +102,42 @@ export declare class Entity {
102102
protected postDispose(): void;
103103
}
104104
/**
105-
* Camera entity for managing the view transform in the game.
105+
* A layer that renders its children directly to the screen, ignoring any camera transforms.
106+
* Ideal for UI elements like HUDs, menus, and scores.
107+
*
108+
* CanvasLayer 是一个特殊的层,它会直接将其子节点渲染到屏幕上,忽略任何摄像机的变换。
109+
* 非常适合用于UI元素,如HUD(状态栏)、菜单和分数显示。
106110
*/
107-
export declare class Camera extends Entity {
108-
/**
109-
* Updates the camera's transform to center the view and apply transformations.
110-
*/
111+
export declare class CanvasLayer extends Entity {
112+
constructor(game: Game);
111113
updateTransform(): void;
112114
}
113115
/**
114-
* Tilemap entity for rendering tiled maps.
116+
* Camera entity for managing the view transform in the game.
115117
*/
116-
export declare class Tilemap extends Entity {
117-
static readonly DEFAULT_ERROR = 0;
118-
static readonly EMPTY_TILE = -1;
119-
error: Vec2;
120-
shape: TilemapShape;
121-
tileSet: TileSet;
122-
data: (number | string)[][];
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;
118+
export declare class Camera extends Entity {
119+
enable: boolean;
120+
center: boolean;
121+
positionSmoothingSpeed: number;
122+
rotationSmoothingSpeed: number;
123+
private _currentRenderPosition;
124+
private _currentRenderRotation;
172125
/**
173-
* Converts local coordinates to map coordinates.
174-
* @param local - The local coordinates to convert.
126+
* 设置此摄像机是否为当前场景的主摄像机。
127+
* @param isEnable
175128
*/
176-
localToMap(local: Vec2): void;
129+
setEnable(isEnable: boolean): void;
130+
constructor(game: Game, options?: ICameraOptions);
177131
/**
178-
* Converts map coordinates to local coordinates.
179-
* @param local - The map coordinates to convert.
132+
* 每帧更新,用于平滑摄像机的【局部】变换属性。
133+
* @param deltaTime
180134
*/
181-
mapToLocal(local: Vec2): void;
135+
onUpdate(deltaTime: number): void;
182136
/**
183-
* Renders the tilemap layer.
184-
* @param render - The rendering engine instance.
137+
* 根据摄像机的【全局】变换计算最终的视图矩阵。
138+
* 这个方法现在正确地处理了父子关系。
185139
*/
186-
onRender(render: Rapid): void;
140+
updateTransform(): void;
187141
}
188142
/**
189143
* Scene class representing a game scene with entities.
@@ -208,12 +162,15 @@ export declare class Game {
208162
private lastTime;
209163
private tweens;
210164
private timers;
165+
mainCamera: Camera | null;
211166
renderQueue: Entity[];
212167
/**
213168
* Creates a new game instance.
214169
* @param options - Configuration options for the game.
215170
*/
216171
constructor(options: IGameOptions);
172+
getMainScene(): Scene | null;
173+
setMainCamera(camera: Camera | null): void;
217174
/**
218175
* Switches to a new scene, disposing of the current one.
219176
* @param newScene - The new scene to switch to.

dist/index.d.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import Rapid from "./render";
2-
import 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";
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';
88
export { Text, Rapid, GLShader, TileMapRender, TileSet, Uniform, ParticleEmitter, graphicAttributes, spriteAttributes, };
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";
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';

dist/input.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Vec2 } from "./math";
2-
import Rapid from "./render";
3-
import { Entity } from "./game";
1+
import { Vec2 } from './math';
2+
import { default as Rapid } from './render';
3+
import { Entity } from './game';
44
/**
55
* Manages user input for keyboard and mouse events.
66
* Tracks key and button states, including pressed/released states for the current and previous frames.

dist/interface.d.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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 GLShader from "./webgl/glshader";
7-
import { Uniform } from "./webgl/uniform";
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';
88
/**
99
* @ignore
1010
*/
@@ -182,6 +182,7 @@ export interface YSortCallback {
182182
renderSprite?: ISpriteRenderOptions;
183183
}
184184
export interface IEntityTilemapLayerOptions extends ITilemapLayerOptions, IEntityTransformOptions {
185+
enableYsort: boolean;
185186
}
186187
export interface ITilemapLayerOptions {
187188
error?: number | Vec2;
@@ -226,6 +227,9 @@ export interface ILightRenderOptions {
226227
}
227228
export interface ICameraOptions extends ITransformOptions {
228229
center?: boolean;
230+
enable?: boolean;
231+
positionSmoothingSpeed?: number;
232+
rotationSmoothingSpeed?: number;
229233
}
230234
/**
231235
* Defines particle emitter shape types
@@ -362,6 +366,8 @@ export type ParticleAttributeData<T extends ParticleAttributeTypes> = {
362366
*/
363367
damping?: number;
364368
};
369+
export interface IParticleEmitterOptions extends IParticleOptions, IEntityTransformOptions {
370+
}
365371
export interface IGameOptions extends IRapidOptions {
366372
}
367373
export interface ISound {

dist/light.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Vec2 } from "./math";
2-
import Rapid from "./render";
1+
import { Vec2 } from './math';
2+
import { default as Rapid } from './render';
33
export declare class LightManager {
44
render: Rapid;
55
constructor(render: Rapid);

dist/line.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ILineStyleOptions } from "./interface";
2-
import { Vec2 } from "./math";
1+
import { ILineStyleOptions } from './interface';
2+
import { Vec2 } from './math';
33
/**
44
* @ignore
55
*/

dist/math.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IMathObject, ITransformOptions, WebGLContext } from "./interface";
1+
import { IMathObject, ITransformOptions, WebGLContext } from './interface';
22
/**
33
* @ignore
44
*/
@@ -455,6 +455,7 @@ export declare class Vec2 implements IMathObject<Vec2> {
455455
* @returns The angle between the two vectors in radians.
456456
*/
457457
angleBetween(v: Vec2): number;
458+
lerp(target: Vec2, factor: number): Vec2;
458459
}
459460
/**
460461
* Provides utility methods for mathematical conversions.

0 commit comments

Comments
 (0)