angry-pixel 1.2.4 → 1.2.6

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.
@@ -1,50 +1,22 @@
1
+ import { Vector2 } from "angry-pixel-math";
1
2
  import { Slice } from "angry-pixel-2d-renderer";
2
3
  export { Slice };
3
- /**
4
- * Sprite configuration options
5
- * @public
6
- */
7
4
  export interface SpriteConfig {
8
- /** The image element to render */
9
5
  image: HTMLImageElement;
10
- /** Cut the image based on straight coordinates starting from the top left downward */
6
+ scale?: Vector2;
11
7
  slice?: Slice;
12
- /** Smoothing pixels (not recommended for pixel art) */
13
8
  smooth?: boolean;
14
9
  }
15
- /**
16
- * The Sprite is an object that is composed of the Image element and allow to slice it and smooth its pixels.
17
- *
18
- * @public
19
- * @example
20
- * ```js
21
- * const sprite = new Sprite({image: this.assetManager.getImage("image.png")});
22
- * ```
23
- *
24
- * @example
25
- * ```js
26
- * const sprite = new Sprite({
27
- * image: this.assetManager.getImage("image.png"),
28
- * slice: {x: 0, y:0, width: 16, height: 16},
29
- * smooth: false
30
- * });
31
- * ```
32
- */
33
10
  export declare class Sprite {
34
- /** The image element to render */
35
11
  readonly image: HTMLImageElement;
36
- /** Cut the image based on straight coordinates starting from the top left downward */
37
12
  readonly slice: Slice;
38
- /** Smoothing pixels (not recommended for pixel art) */
39
13
  readonly smooth: boolean;
14
+ scale?: Vector2;
40
15
  private _width;
41
16
  private _height;
42
17
  private _loaded;
43
18
  constructor(config: SpriteConfig);
44
- /** The image width */
45
19
  get width(): number;
46
- /** The image height */
47
20
  get height(): number;
48
- /** TRUE if the image is loaded */
49
21
  get loaded(): boolean;
50
22
  }
@@ -1,6 +1,6 @@
1
1
  import { ColliderComponent, RenderComponent } from "../../core/Component";
2
2
  import { GameObject } from "../../core/GameObject";
3
- import { ICollisionResolution, ICollider } from "angry-pixel-2d-physics";
3
+ import { ICollisionResolution, ICollider, ICollision } from "angry-pixel-2d-physics";
4
4
  /**
5
5
  * Information about the collision
6
6
  * @public
@@ -17,6 +17,8 @@ export interface CollisionData {
17
17
  * @return The object on the other side of the collision.
18
18
  */
19
19
  getGameObject: <T extends GameObject>() => T;
20
+ /** The collider belonging to the queried component */
21
+ localCollider: ICollider;
20
22
  }
21
23
  /**
22
24
  * Every collider component implements this interface.
@@ -74,7 +76,7 @@ export declare abstract class BaseCollider extends ColliderComponent implements
74
76
  * @returns The collection of collision data
75
77
  */
76
78
  getCollisionsWithLayer(layer: string): CollisionData[];
77
- private createCollisionData;
79
+ protected createCollisionData(collision: ICollision): CollisionData;
78
80
  protected onActiveChange(): void;
79
81
  protected onDestroy(): void;
80
82
  }
@@ -26,7 +26,8 @@ export interface TilemapColliderOptions extends InitOptions {
26
26
  debug?: boolean;
27
27
  }
28
28
  /**
29
- * Generates rectanble colliders for the map edge tiles (or lines if composite is TRUE).
29
+ * Generates rectangle colliders for the map edge tiles (or lines if composite is TRUE).
30
+ * **Limitations:** At the moment, it is not possible to modify the shape, position, scale and rotation of the collider once it has been generated.
30
31
  * @public
31
32
  * @category Components
32
33
  * @example
@@ -34,8 +34,8 @@ export interface TiledTilemapRendererOptions {
34
34
  tilemapLayer: string;
35
35
  /** The Tileset instance */
36
36
  tileset: Tileset;
37
- tileWidth: number;
38
- tileHeight: number;
37
+ tileWidth?: number;
38
+ tileHeight?: number;
39
39
  /** The render layer */
40
40
  layer?: string;
41
41
  /** Direction in which the tilemap will be rendered. */
@@ -89,6 +89,7 @@ export interface TiledTilemapRendererOptions {
89
89
  * ```
90
90
  */
91
91
  export declare class TiledTilemapRenderer extends RenderComponent implements ITilemapRenderer {
92
+ private readonly spriteDefaultScale;
92
93
  /**
93
94
  * Id of tiles separated by commas. The ids start at 1, and increment from left to right,
94
95
  * from top to bottom. ID 0 (zero) represents a space with no tile.
@@ -126,7 +127,7 @@ export declare class TiledTilemapRenderer extends RenderComponent implements ITi
126
127
  */
127
128
  realHeight: number;
128
129
  private tiledData;
129
- private tilemapLayer;
130
+ private tiledLayer;
130
131
  private tileset;
131
132
  private layer;
132
133
  private smooth?;
@@ -61,8 +61,8 @@ export interface TilemapRendererOptions {
61
61
  /** The Tileset instance */
62
62
  tileset: Tileset;
63
63
  width: number;
64
- tileWidth: number;
65
- tileHeight: number;
64
+ tileWidth?: number;
65
+ tileHeight?: number;
66
66
  /** The render layer */
67
67
  layer?: string;
68
68
  /** Direction in which the tilemap will be rendered. */
@@ -128,6 +128,7 @@ export interface ITilemapRenderer {
128
128
  * ```
129
129
  */
130
130
  export declare class TilemapRenderer extends RenderComponent implements ITilemapRenderer {
131
+ private readonly spriteDefaultScale;
131
132
  /** Id of tiles separated by commas. The ids start at 1, and increment from left to right,
132
133
  * from top to bottom. ID 0 (zero) represents a space with no tile. */
133
134
  tiles: number[];
@@ -66,10 +66,33 @@ export declare class Game {
66
66
  *
67
67
  * @param sceneClass the class of the scene
68
68
  * @param name The name of the scene
69
- * @param options [optional] This options will be passed to the init method
70
- * @param openingScene [default FALSE] If this is the opening scene, set TRUE, FALSE instead
71
69
  */
72
- addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
70
+ addScene(sceneClass: SceneClass, name: string): void;
71
+ /**
72
+ * Add a scene to the game
73
+ *
74
+ * @param sceneClass the class of the scene
75
+ * @param name The name of the scene
76
+ * @param options This options will be passed to the init method
77
+ */
78
+ addScene(sceneClass: SceneClass, name: string, options: InitOptions): void;
79
+ /**
80
+ * Add a scene to the game
81
+ *
82
+ * @param sceneClass the class of the scene
83
+ * @param name The name of the scene
84
+ * @param openingScene If this is the opening scene, set TRUE, FALSE instead
85
+ */
86
+ addScene(sceneClass: SceneClass, name: string, openingScene: boolean): void;
87
+ /**
88
+ * Add a scene to the game
89
+ *
90
+ * @param sceneClass the class of the scene
91
+ * @param name The name of the scene
92
+ * @param options This options will be passed to the init method
93
+ * @param openingScene If this is the opening scene, set TRUE, FALSE instead
94
+ */
95
+ addScene(sceneClass: SceneClass, name: string, options: InitOptions, openingScene: boolean): void;
73
96
  /**
74
97
  * Run the game
75
98
  */
@@ -100,6 +100,7 @@ export interface IGameObjectManager {
100
100
  export declare class GameObjectManager implements IGameObjectManager {
101
101
  private readonly container;
102
102
  private gameObjects;
103
+ private lastId;
103
104
  constructor(container: Container);
104
105
  addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, parent?: GameObject, name?: string): T;
105
106
  findGameObjects<T extends GameObject>(gameObjectClass?: GameObjectClass<T>): T[];
@@ -10,11 +10,14 @@ export declare class HeadlessIterationManager implements IIterationManager {
10
10
  private readonly gameObjectManager;
11
11
  private readonly sceneManager;
12
12
  running: boolean;
13
- private currentScene;
13
+ private loadedScene;
14
14
  private gameObjects;
15
15
  private components;
16
16
  private gameInterval;
17
17
  private physicsInterval;
18
+ private changingScene;
19
+ private readonly sceneEvents;
20
+ private readonly gameObjectEvents;
18
21
  constructor(timeManager: ITimeManager, physicsManager: IPhysicsManager, gameObjectManager: IGameObjectManager, sceneManager: ISceneManager);
19
22
  start(): void;
20
23
  pause(): void;
@@ -40,10 +40,13 @@ export declare class IterationManager implements IIterationManager {
40
40
  private readonly canvasColor;
41
41
  running: boolean;
42
42
  private gameLoopAccumulator;
43
- private currentScene;
43
+ private loadedScene;
44
44
  private gameObjects;
45
45
  private components;
46
46
  private physicsIntervalId;
47
+ private changingScene;
48
+ private readonly sceneEvents;
49
+ private readonly gameObjectEvents;
47
50
  constructor(timeManager: ITimeManager, physicsManager: IPhysicsManager, renderManager: IRenderManager, inputManager: IInputManager, gameObjectManager: IGameObjectManager, sceneManager: ISceneManager, canvasColor: string);
48
51
  start(): void;
49
52
  pause(): void;
@@ -9,14 +9,10 @@ import { Container } from "../../utils/Container";
9
9
  * @example
10
10
  * ```js
11
11
  * this.sceneManager.loadScene("MainScene");
12
+ * const loadedScene = this.sceneManager.getLoadedScene();
12
13
  * ```
13
14
  */
14
15
  export interface ISceneManager {
15
- /**
16
- * Retrieves the current loaded scene.
17
- * @returns The scene instance.
18
- */
19
- getCurrentScene<T extends Scene>(): T;
20
16
  /**
21
17
  * Adds a new scene.
22
18
  * @param sceneClass The scene class .
@@ -25,19 +21,37 @@ export interface ISceneManager {
25
21
  * @param openingScene [optional] TRUE if it's the first scene to load.
26
22
  */
27
23
  addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
28
- /** Loads the scene flagged as the opening scene. */
29
- loadOpeningScene(): void;
30
24
  /**
31
25
  * Loads a Scene by the given name.
32
26
  * @param name The name of the Scene.
33
27
  */
34
28
  loadScene(name: string): void;
35
- /** @private */
36
- update(): void;
37
- /** @private */
29
+ /**
30
+ * Retrieves the current loaded scene.
31
+ * @returns The scene instance.
32
+ */
33
+ getLoadedScene<T extends Scene>(): T;
34
+ /**
35
+ * Loads the scene flagged as the opening scene.
36
+ * @private
37
+ */
38
+ loadOpeningScene(): void;
39
+ /**
40
+ * Check if there is a pending scene change.
41
+ * @return TRUE if there is a pending scene to load, FALSE instead
42
+ * @private
43
+ */
44
+ pendingSceneToload(): boolean;
45
+ /**
46
+ * Loads the next pending scene.
47
+ * @private
48
+ */
49
+ loadPendingScene(): void;
50
+ /**
51
+ * Unloads the current loaded scene.
52
+ * @private
53
+ */
38
54
  unloadCurrentScene(): void;
39
- /** @private */
40
- stopGame(): void;
41
55
  }
42
56
  /** @private */
43
57
  export declare class SceneManager implements ISceneManager {
@@ -46,14 +60,34 @@ export declare class SceneManager implements ISceneManager {
46
60
  private scenes;
47
61
  private currentScene;
48
62
  private openingSceneName;
49
- private sceneToLoad;
63
+ private sceneNamePendingToLoad;
50
64
  constructor(container: Container, renderManager?: IRenderManager);
51
- getCurrentScene<T extends Scene>(): T;
65
+ /**
66
+ * @inheritdoc
67
+ */
52
68
  addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
53
- loadOpeningScene(): void;
69
+ /**
70
+ * @inheritdoc
71
+ */
54
72
  loadScene(name: string): void;
55
- update(): void;
56
- private _loadScene;
73
+ /**
74
+ * @inheritdoc
75
+ */
76
+ getLoadedScene<T extends Scene>(): T;
77
+ /**
78
+ * @inheritdoc
79
+ */
80
+ loadOpeningScene(): void;
81
+ /**
82
+ * @inheritdoc
83
+ */
84
+ pendingSceneToload(): boolean;
85
+ /**
86
+ * @inheritdoc
87
+ */
88
+ loadPendingScene(): void;
89
+ /**
90
+ * @inheritdoc
91
+ */
57
92
  unloadCurrentScene(): void;
58
- stopGame(): void;
59
93
  }