angry-pixel 2.0.14 → 2.0.16
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/lib/index.cjs.js +1 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +167 -60
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -247,6 +247,7 @@ declare class Vector2 {
|
|
|
247
247
|
* ```
|
|
248
248
|
*/
|
|
249
249
|
static round(out: Vector2, a: Vector2): Vector2;
|
|
250
|
+
toString(): string;
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
/**
|
|
@@ -1226,6 +1227,138 @@ declare class AssetManager {
|
|
|
1226
1227
|
private createAsset;
|
|
1227
1228
|
}
|
|
1228
1229
|
|
|
1230
|
+
type IntervalOptions = {
|
|
1231
|
+
callback: () => void;
|
|
1232
|
+
delay: number;
|
|
1233
|
+
times?: number;
|
|
1234
|
+
executeImmediately?: boolean;
|
|
1235
|
+
};
|
|
1236
|
+
/**
|
|
1237
|
+
* Manages the properties associated with time.
|
|
1238
|
+
* @public
|
|
1239
|
+
* @category Managers
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```js
|
|
1242
|
+
* // using deltaTime to increment a timer
|
|
1243
|
+
* this.timer += this.timeManager.deltaTime;
|
|
1244
|
+
*
|
|
1245
|
+
* // using physicsDeltaTime within a physics component to move the object it belongs to
|
|
1246
|
+
* this.transform.position.x += speed * this.timeManager.physicsDeltaTime;
|
|
1247
|
+
*
|
|
1248
|
+
* // stop all time-related interactions by setting the scale to zero
|
|
1249
|
+
* this.timeManager.timeScale = 0;
|
|
1250
|
+
*
|
|
1251
|
+
* // set an interval that will be cleared after being called 5 times
|
|
1252
|
+
* const intervalId = timeManager.setInterval({
|
|
1253
|
+
* callback: () => console.log("Will be called 5 times!"),
|
|
1254
|
+
* delay: 1000,
|
|
1255
|
+
* times: 5,
|
|
1256
|
+
* });
|
|
1257
|
+
*
|
|
1258
|
+
* // set an interval that will be called indefinitely
|
|
1259
|
+
* const intervalId = timeManager.setInterval({
|
|
1260
|
+
* callback: () => console.log("Will be called indefinitely!"),
|
|
1261
|
+
* delay: 1000,
|
|
1262
|
+
* });
|
|
1263
|
+
*
|
|
1264
|
+
* // set an interval that will be called immediately and indefinitely
|
|
1265
|
+
* const intervalId = timeManager.setInterval({
|
|
1266
|
+
* callback: () => console.log("Will be called immediately and indefinitely!"),
|
|
1267
|
+
* delay: 1000,
|
|
1268
|
+
* executeImmediately: true,
|
|
1269
|
+
* });
|
|
1270
|
+
*
|
|
1271
|
+
* // clear the interval with the given id
|
|
1272
|
+
* this.timeManager.clearInterval(intervalId);
|
|
1273
|
+
* ```
|
|
1274
|
+
*/
|
|
1275
|
+
declare class TimeManager {
|
|
1276
|
+
/** @internal */
|
|
1277
|
+
readonly fixedGameFramerate: number;
|
|
1278
|
+
/** @internal */
|
|
1279
|
+
readonly fixedGameDeltaTime: number;
|
|
1280
|
+
/** @internal */
|
|
1281
|
+
readonly fixedPhysicsFramerate: number;
|
|
1282
|
+
/** @internal */
|
|
1283
|
+
readonly fixedPhysicsDeltaTime: number;
|
|
1284
|
+
/**
|
|
1285
|
+
* The scale on which time passes. The default value is 1.\
|
|
1286
|
+
* For example, if set to 2, the time will run at twice the speed.\
|
|
1287
|
+
* If set to 0.5, it will run at half the speed.\
|
|
1288
|
+
* If set to 0, everything associated with the time will stop.
|
|
1289
|
+
*/
|
|
1290
|
+
timeScale: number;
|
|
1291
|
+
/** The time difference, in seconds, between the last frame of and the current frame recorded by the browser. */
|
|
1292
|
+
browserDeltaTime: number;
|
|
1293
|
+
/** The time difference, in seconds, between the last frame and the current frame, unaffected by the scale. */
|
|
1294
|
+
unscaledDeltaTime: number;
|
|
1295
|
+
/** The time difference, in seconds, between the last physics frame and the current one, unaffected by the scale. */
|
|
1296
|
+
unscaledPhysicsDeltaTime: number;
|
|
1297
|
+
private maxDeltaTime;
|
|
1298
|
+
private thenForGame;
|
|
1299
|
+
private thenForPhysics;
|
|
1300
|
+
private thenForRender;
|
|
1301
|
+
private lastIntervalId;
|
|
1302
|
+
private intervals;
|
|
1303
|
+
/** The time difference, in seconds, between the last frame and the current frame. */
|
|
1304
|
+
get deltaTime(): number;
|
|
1305
|
+
/** The time difference, in seconds, between the last physics frame and the current one. */
|
|
1306
|
+
get physicsDeltaTime(): number;
|
|
1307
|
+
/** The browser delta time affected by time scale. */
|
|
1308
|
+
get renderDeltaTime(): number;
|
|
1309
|
+
constructor({ physicsFramerate }: GameConfig);
|
|
1310
|
+
/** @internal */
|
|
1311
|
+
updateForRender(time: number): void;
|
|
1312
|
+
/** @internal */
|
|
1313
|
+
updateForGame(time: number): void;
|
|
1314
|
+
/** @internal */
|
|
1315
|
+
updateForPhysics(time: number): void;
|
|
1316
|
+
/** @internal */
|
|
1317
|
+
updateIntervals(): void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Sets a timer which executes a function repeatedly at a fixed time interval.\
|
|
1320
|
+
* If `times` is provided, the interval will be cleared after the function has been called that many times.\
|
|
1321
|
+
* But if `times` is not provided, the interval will continue until it is cleared.\
|
|
1322
|
+
* If `executeImmediately` is set to true, the function will be called immediately after the interval is set.\
|
|
1323
|
+
* Intervals are cleared when loading a new scene.
|
|
1324
|
+
* @param intervalOptions
|
|
1325
|
+
* @returns intervalId
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```ts
|
|
1328
|
+
* const intervalId = timeManager.setInterval({
|
|
1329
|
+
* callback: () => console.log("Will be called 5 times!"),
|
|
1330
|
+
* delay: 1000,
|
|
1331
|
+
* times: 5,
|
|
1332
|
+
* });
|
|
1333
|
+
* ```
|
|
1334
|
+
* @example
|
|
1335
|
+
* ```ts
|
|
1336
|
+
* const intervalId = timeManager.setInterval({
|
|
1337
|
+
* callback: () => console.log("Will be called indefinitely!"),
|
|
1338
|
+
* delay: 1000,
|
|
1339
|
+
* });
|
|
1340
|
+
* ```
|
|
1341
|
+
* @example
|
|
1342
|
+
* ```ts
|
|
1343
|
+
* const intervalId = timeManager.setInterval({
|
|
1344
|
+
* callback: () => console.log("Will be called immediately and indefinitely!"),
|
|
1345
|
+
* delay: 1000,
|
|
1346
|
+
* executeImmediately: true,
|
|
1347
|
+
* });
|
|
1348
|
+
* ```
|
|
1349
|
+
*/
|
|
1350
|
+
setInterval({ callback, delay, times, executeImmediately }: IntervalOptions): number;
|
|
1351
|
+
/**
|
|
1352
|
+
* Clears the interval with the given id.
|
|
1353
|
+
* @param intervalId
|
|
1354
|
+
*/
|
|
1355
|
+
clearInterval(intervalId: number): void;
|
|
1356
|
+
/**
|
|
1357
|
+
* Clears all intervals.
|
|
1358
|
+
*/
|
|
1359
|
+
clearAllIntervals(): void;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1229
1362
|
/**
|
|
1230
1363
|
* This type represents a scene class
|
|
1231
1364
|
* @public
|
|
@@ -1284,17 +1417,20 @@ declare class SceneManager {
|
|
|
1284
1417
|
private readonly systemFactory;
|
|
1285
1418
|
private readonly entityManager;
|
|
1286
1419
|
private readonly assetManager;
|
|
1420
|
+
private readonly timeManager;
|
|
1287
1421
|
private readonly scenes;
|
|
1288
1422
|
private openingSceneName;
|
|
1289
1423
|
private currentSceneName;
|
|
1290
1424
|
private sceneNameToBeLoaded;
|
|
1291
1425
|
private _loadingScene;
|
|
1426
|
+
private _sceneLoadedThisFrame;
|
|
1292
1427
|
/** @internal */
|
|
1293
|
-
constructor(systemManager: SystemManager, systemFactory: CreateSystemService, entityManager: EntityManager, assetManager: AssetManager);
|
|
1428
|
+
constructor(systemManager: SystemManager, systemFactory: CreateSystemService, entityManager: EntityManager, assetManager: AssetManager, timeManager: TimeManager);
|
|
1294
1429
|
addScene(sceneType: SceneType, name: string, openingScene?: boolean): void;
|
|
1295
1430
|
loadScene(name: string): void;
|
|
1296
1431
|
loadOpeningScene(): void;
|
|
1297
|
-
loadingScene(): boolean;
|
|
1432
|
+
get loadingScene(): boolean;
|
|
1433
|
+
get sceneLoadedThisFrame(): boolean;
|
|
1298
1434
|
/** @internal */
|
|
1299
1435
|
update(): void;
|
|
1300
1436
|
private destroyCurrentScene;
|
|
@@ -2234,6 +2370,7 @@ interface SpriteRenderData extends RenderData {
|
|
|
2234
2370
|
maskColor?: string;
|
|
2235
2371
|
maskColorMix?: number;
|
|
2236
2372
|
tintColor?: string;
|
|
2373
|
+
tiled?: Vector2;
|
|
2237
2374
|
}
|
|
2238
2375
|
/**
|
|
2239
2376
|
* Cut the image based on straight coordinates starting from the top left downward.
|
|
@@ -2524,10 +2661,30 @@ interface SpriteRendererOptions {
|
|
|
2524
2661
|
scale: Vector2;
|
|
2525
2662
|
width: number;
|
|
2526
2663
|
height: number;
|
|
2664
|
+
tiled: Vector2;
|
|
2527
2665
|
}
|
|
2528
2666
|
/**
|
|
2529
2667
|
* @public
|
|
2530
2668
|
* @category Components
|
|
2669
|
+
* @example
|
|
2670
|
+
* ```js
|
|
2671
|
+
* spriteRenderer.image = this.assetManager.getImage("image.png");
|
|
2672
|
+
* spriteRenderer.width = 1920;
|
|
2673
|
+
* spriteRenderer.height = 1080;
|
|
2674
|
+
* spriteRenderer.offset = new Vector2(0, 0);
|
|
2675
|
+
* spriteRenderer.flipHorizontally = false;
|
|
2676
|
+
* spriteRenderer.flipVertically = false;
|
|
2677
|
+
* spriteRenderer.rotation = 0;
|
|
2678
|
+
* spriteRenderer.opacity = 1;
|
|
2679
|
+
* spriteRenderer.maskColor = "#FF0000";
|
|
2680
|
+
* spriteRenderer.maskColorMix = 0;
|
|
2681
|
+
* spriteRenderer.tintColor = "#00FF00";
|
|
2682
|
+
* spriteRenderer.layer = "Default";
|
|
2683
|
+
* spriteRenderer.slice = {x: 0, y:0, width: 1920, height: 1080};
|
|
2684
|
+
* spriteRenderer.scale = new Vector2(1, 1);
|
|
2685
|
+
* spriteRenderer.tiled = new Vector2(1, 1);
|
|
2686
|
+
* spriteRenderer.smooth = false;
|
|
2687
|
+
* ```
|
|
2531
2688
|
*/
|
|
2532
2689
|
declare class SpriteRenderer {
|
|
2533
2690
|
/** The render layer */
|
|
@@ -2560,6 +2717,8 @@ declare class SpriteRenderer {
|
|
|
2560
2717
|
width: number;
|
|
2561
2718
|
/** Overwrite the original image height */
|
|
2562
2719
|
height: number;
|
|
2720
|
+
/** Enable tiled draw mode */
|
|
2721
|
+
tiled: Vector2;
|
|
2563
2722
|
/** @internal */
|
|
2564
2723
|
_renderData: SpriteRenderData;
|
|
2565
2724
|
constructor(options?: Partial<SpriteRendererOptions>);
|
|
@@ -3176,63 +3335,6 @@ declare class InputManager {
|
|
|
3176
3335
|
constructor();
|
|
3177
3336
|
}
|
|
3178
3337
|
|
|
3179
|
-
/**
|
|
3180
|
-
* Manages the properties associated with time.
|
|
3181
|
-
* @public
|
|
3182
|
-
* @category Managers
|
|
3183
|
-
* @example
|
|
3184
|
-
* ```js
|
|
3185
|
-
* // using deltaTime to increment a timer
|
|
3186
|
-
* this.timer += this.timeManager.deltaTime;
|
|
3187
|
-
*
|
|
3188
|
-
* // using physicsDeltaTime within a physics component to move the object it belongs to
|
|
3189
|
-
* this.transform.position.x += speed * this.timeManager.physicsDeltaTime;
|
|
3190
|
-
*
|
|
3191
|
-
* // stop all time-related interactions by setting the scale to zero
|
|
3192
|
-
* this.timeManager.timeScale = 0;
|
|
3193
|
-
* ```
|
|
3194
|
-
*/
|
|
3195
|
-
declare class TimeManager {
|
|
3196
|
-
/** @internal */
|
|
3197
|
-
readonly fixedGameFramerate: number;
|
|
3198
|
-
/** @internal */
|
|
3199
|
-
readonly fixedGameDeltaTime: number;
|
|
3200
|
-
/** @internal */
|
|
3201
|
-
readonly fixedPhysicsFramerate: number;
|
|
3202
|
-
/** @internal */
|
|
3203
|
-
readonly fixedPhysicsDeltaTime: number;
|
|
3204
|
-
/**
|
|
3205
|
-
* The scale on which time passes. The default value is 1.\
|
|
3206
|
-
* For example, if set to 2, the time will run at twice the speed.\
|
|
3207
|
-
* If set to 0.5, it will run at half the speed.\
|
|
3208
|
-
* If set to 0, everything associated with the time will stop.
|
|
3209
|
-
*/
|
|
3210
|
-
timeScale: number;
|
|
3211
|
-
/** The time difference, in seconds, between the last frame of and the current frame recorded by the browser. */
|
|
3212
|
-
browserDeltaTime: number;
|
|
3213
|
-
/** The time difference, in seconds, between the last frame and the current frame, unaffected by the scale. */
|
|
3214
|
-
unscaledDeltaTime: number;
|
|
3215
|
-
/** The time difference, in seconds, between the last physics frame and the current one, unaffected by the scale. */
|
|
3216
|
-
unscaledPhysicsDeltaTime: number;
|
|
3217
|
-
private maxDeltaTime;
|
|
3218
|
-
private thenForGame;
|
|
3219
|
-
private thenForPhysics;
|
|
3220
|
-
private thenForRender;
|
|
3221
|
-
/** The time difference, in seconds, between the last frame and the current frame. */
|
|
3222
|
-
get deltaTime(): number;
|
|
3223
|
-
/** The time difference, in seconds, between the last physics frame and the current one. */
|
|
3224
|
-
get physicsDeltaTime(): number;
|
|
3225
|
-
/** The browser delta time affected by time scale. */
|
|
3226
|
-
get renderDeltaTime(): number;
|
|
3227
|
-
constructor({ physicsFramerate }: GameConfig);
|
|
3228
|
-
/** @internal */
|
|
3229
|
-
updateForRender(time: number): void;
|
|
3230
|
-
/** @internal */
|
|
3231
|
-
updateForGame(time: number): void;
|
|
3232
|
-
/** @internal */
|
|
3233
|
-
updateForPhysics(time: number): void;
|
|
3234
|
-
}
|
|
3235
|
-
|
|
3236
3338
|
/**
|
|
3237
3339
|
* Abstract class which can be used to create Systems.\
|
|
3238
3340
|
* It includes the following dependencies: EntityManager, AssetManager, SceneManager, TimeManager, InputManager, CollisionRepository.
|
|
@@ -3254,7 +3356,12 @@ declare abstract class GameSystem implements System {
|
|
|
3254
3356
|
protected readonly timeManager: TimeManager;
|
|
3255
3357
|
protected readonly inputManager: InputManager;
|
|
3256
3358
|
protected readonly collisionRepository: CollisionRepository;
|
|
3359
|
+
protected readonly gameConfig: GameConfig;
|
|
3257
3360
|
onUpdate(): void;
|
|
3361
|
+
onCreate(): void;
|
|
3362
|
+
onEnabled(): void;
|
|
3363
|
+
onDisabled(): void;
|
|
3364
|
+
onDestroy(): void;
|
|
3258
3365
|
}
|
|
3259
3366
|
|
|
3260
3367
|
/**
|
|
@@ -3311,4 +3418,4 @@ declare const Symbols: {
|
|
|
3311
3418
|
TimeManager: symbol;
|
|
3312
3419
|
};
|
|
3313
3420
|
|
|
3314
|
-
export { Animation, type AnimationSlice, Animator, type AnimatorOptions, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, Children, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, InputManager, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, Parent, Polygon, PolygonCollider, type PolygonColliderOptions, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, Symbols, type System, type SystemGroup, SystemManager, type SystemType, TextOrientation, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, defaultRenderLayer, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, randomFloat, randomInt, range };
|
|
3421
|
+
export { Animation, type AnimationSlice, Animator, type AnimatorOptions, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, Children, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, InputManager, type IntervalOptions, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, Parent, Polygon, PolygonCollider, type PolygonColliderOptions, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, Symbols, type System, type SystemGroup, SystemManager, type SystemType, TextOrientation, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, defaultRenderLayer, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, randomFloat, randomInt, range };
|