angry-pixel 1.1.5 → 1.1.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.
@@ -10,8 +10,8 @@ export interface SpriteConfig {
10
10
  export declare class Sprite {
11
11
  readonly image: HTMLImageElement;
12
12
  readonly slice: Slice;
13
- readonly scale: Vector2;
14
13
  readonly smooth: boolean;
14
+ scale?: Vector2;
15
15
  private _width;
16
16
  private _height;
17
17
  private _loaded;
@@ -1,5 +1,4 @@
1
1
  import { Collider } from "./Collider";
2
- import { GameObject } from "../../core/GameObject";
3
2
  import { InitOptions } from "../../core/GameActor";
4
3
  import { Vector2, Rotation } from "angry-pixel-math";
5
4
  export interface EdgeColliderOptions extends InitOptions {
@@ -22,7 +21,6 @@ export declare class EdgeCollider extends Collider {
22
21
  private scaledPosition;
23
22
  private finalRotation;
24
23
  private innerPosition;
25
- constructor(gameObject: GameObject, name?: string);
26
24
  protected init(config: EdgeColliderOptions): void;
27
25
  protected start(): void;
28
26
  protected update(): void;
@@ -2,7 +2,6 @@ import { Collider } from "./Collider";
2
2
  import { ColliderData } from "../../physics/collision/ColliderData";
3
3
  import { RenderComponent } from "../../core/Component";
4
4
  import { InitOptions } from "../../core/GameActor";
5
- import { GameObject } from "../../core/GameObject";
6
5
  import { Vector2, Rotation } from "angry-pixel-math";
7
6
  export interface PolygonColliderOptions extends InitOptions {
8
7
  vertexModel: Vector2[];
@@ -24,7 +23,6 @@ export declare class PolygonCollider extends Collider {
24
23
  private scaledPosition;
25
24
  private finalRotation;
26
25
  private innerPosition;
27
- constructor(gameObject: GameObject, name?: string);
28
26
  protected init(config: PolygonColliderOptions): void;
29
27
  protected start(): void;
30
28
  protected update(): void;
@@ -15,7 +15,8 @@ export interface SpriteRendererOptions {
15
15
  layer?: string;
16
16
  }
17
17
  export declare class SpriteRenderer extends RenderComponent {
18
- private renderManager;
18
+ private readonly renderManager;
19
+ private readonly spriteDefaultScale;
19
20
  sprite: Sprite;
20
21
  offset: Vector2;
21
22
  flipHorizontal: boolean;
@@ -2,15 +2,15 @@ import { GameObject } from "./GameObject";
2
2
  import { Scene } from "./Scene";
3
3
  import { FrameEvent } from "./managers/IterationManager";
4
4
  import { GameActor } from "./GameActor";
5
- export declare type ComponentClass<T extends Component = Component> = new (gameObject: GameObject, name?: string) => T;
5
+ import { Container } from "../utils/Container";
6
+ export declare type ComponentClass<T extends Component = Component> = new (container: Container, gameObject: GameObject, name?: string) => T;
6
7
  export declare abstract class Component extends GameActor {
7
- private readonly sceneManager;
8
8
  readonly id: string;
9
9
  readonly name: string;
10
10
  readonly gameObject: GameObject;
11
11
  readonly allowMultiple: boolean;
12
12
  private _active;
13
- constructor(gameObject: GameObject, name?: string);
13
+ constructor(container: Container, gameObject: GameObject, name?: string);
14
14
  get active(): boolean;
15
15
  set active(active: boolean);
16
16
  /**
@@ -1,31 +1,8 @@
1
- import { SceneClass } from "../core/managers/SceneManager";
2
- import { Container } from "../utils/Container";
3
- import { Rectangle, Vector2 } from "angry-pixel-math";
4
- import { CollisionMatrix } from "../physics/collision/CollisionManager";
5
1
  import { InitOptions } from "./GameActor";
6
- export declare const container: Container;
7
- export interface GameConfig {
8
- containerNode?: HTMLElement | null;
9
- gameWidth?: number;
10
- gameHeight?: number;
11
- debugEnabled?: boolean;
12
- canvasColor?: string;
13
- physicsFramerate?: number;
14
- spriteDefaultScale?: Vector2 | null;
15
- headless?: boolean;
16
- collisions?: {
17
- method?: CollisionMethodConfig;
18
- quadTreeBounds?: Rectangle | null;
19
- quadMaxLevel?: number;
20
- collidersPerQuad?: number;
21
- collisionMatrix?: CollisionMatrix;
22
- };
23
- }
24
- export declare enum CollisionMethodConfig {
25
- AABB = "aabb",
26
- SAT = "sat"
27
- }
2
+ import { GameConfig } from "./GameConfig";
3
+ import { SceneClass } from "./Scene";
28
4
  export declare class Game {
5
+ private readonly container;
29
6
  private sceneManager;
30
7
  private iterationManager;
31
8
  private _config;
@@ -1,3 +1,4 @@
1
+ import { Container } from "../utils/Container";
1
2
  import { GameObject, GameObjectClass } from "./GameObject";
2
3
  import { GameObjectManager } from "./managers/GameObjectManager";
3
4
  import { FrameEvent } from "./managers/IterationManager";
@@ -7,7 +8,9 @@ export interface InitOptions {
7
8
  export declare abstract class GameActor {
8
9
  protected readonly gameObjectManager: GameObjectManager;
9
10
  protected readonly updateEvent: FrameEvent;
11
+ protected readonly container: Container;
10
12
  private started;
13
+ constructor(container: Container);
11
14
  dispatch(event: FrameEvent, options?: InitOptions): void;
12
15
  /**
13
16
  * This method is called after instantiation (recommended for the creation of game objects).
@@ -0,0 +1,23 @@
1
+ import { Rectangle, Vector2 } from "angry-pixel-math";
2
+ import { CollisionMatrix } from "../physics/collision/CollisionManager";
3
+ export declare enum CollisionMethodConfig {
4
+ AABB = "aabb",
5
+ SAT = "sat"
6
+ }
7
+ export interface GameConfig {
8
+ containerNode?: HTMLElement | null;
9
+ gameWidth?: number;
10
+ gameHeight?: number;
11
+ debugEnabled?: boolean;
12
+ canvasColor?: string;
13
+ physicsFramerate?: number;
14
+ spriteDefaultScale?: Vector2 | null;
15
+ headless?: boolean;
16
+ collisions?: {
17
+ method?: CollisionMethodConfig;
18
+ quadTreeBounds?: Rectangle | null;
19
+ quadMaxLevel?: number;
20
+ collidersPerQuad?: number;
21
+ collisionMatrix?: CollisionMatrix;
22
+ };
23
+ }
@@ -3,8 +3,9 @@ import { Transform } from "../component/Transform";
3
3
  import { RigidBody } from "../component/RigidBody";
4
4
  import { Scene } from "./Scene";
5
5
  import { GameActor, InitOptions } from "./GameActor";
6
+ import { Container } from "../utils/Container";
6
7
  export declare const LAYER_DEFAULT = "Default";
7
- export declare type GameObjectClass<T extends GameObject = GameObject> = new (name?: string, parent?: GameObject) => T;
8
+ export declare type GameObjectClass<T extends GameObject = GameObject> = new (container: Container, name?: string, parent?: GameObject) => T;
8
9
  export declare class GameObject extends GameActor {
9
10
  readonly id: string;
10
11
  readonly name: string;
@@ -14,11 +15,10 @@ export declare class GameObject extends GameActor {
14
15
  keep: boolean;
15
16
  private _parent;
16
17
  private _active;
17
- private sceneManager;
18
18
  private components;
19
19
  private activeComponentsCache;
20
20
  private activeChildrenCache;
21
- constructor(name?: string, parent?: GameObject);
21
+ constructor(container: Container, name?: string, parent?: GameObject);
22
22
  get active(): boolean;
23
23
  set active(active: boolean);
24
24
  get parent(): GameObject | null;
@@ -1,10 +1,12 @@
1
1
  import { GameCamera } from "../gameObject/GameCamera";
2
+ import { Container } from "../utils/Container";
2
3
  import { Game } from "./Game";
3
4
  import { GameActor } from "./GameActor";
5
+ export declare type SceneClass = new (container: Container, name: string, game: Game) => Scene;
4
6
  export declare class Scene extends GameActor {
5
7
  readonly name: string;
6
8
  readonly game: Game;
7
- constructor(name: string, game: Game);
9
+ constructor(container: Container, name: string, game: Game);
8
10
  get gameCamera(): GameCamera;
9
11
  protected _destroy(): void;
10
12
  }
@@ -1,3 +1,3 @@
1
- import { GameConfig } from "../Game";
2
1
  import { Container } from "../../utils/Container";
2
+ import { GameConfig } from "../GameConfig";
3
3
  export declare const loadDependencies: (container: Container, gameConfig: GameConfig) => void;
@@ -1,7 +1,10 @@
1
1
  import { GameObject, GameObjectClass } from "../GameObject";
2
2
  import { InitOptions } from "../GameActor";
3
+ import { Container } from "../../utils/Container";
3
4
  export declare class GameObjectManager {
5
+ private readonly container;
4
6
  private gameObjects;
7
+ constructor(container: Container);
5
8
  addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, parent?: GameObject, name?: string): T;
6
9
  findGameObjects<T extends GameObject>(gameObjectClass?: GameObjectClass<T>): T[];
7
10
  findGameObjectById<T extends GameObject>(id: string): T;
@@ -1,9 +1,10 @@
1
1
  import { Game } from "../Game";
2
- import { Scene } from "../Scene";
2
+ import { Scene, SceneClass } from "../Scene";
3
3
  import { IRenderManager } from "angry-pixel-2d-renderer";
4
4
  import { InitOptions } from "../GameActor";
5
- export declare type SceneClass = new (name: string, game: Game) => Scene;
5
+ import { Container } from "../../utils/Container";
6
6
  export declare class SceneManager {
7
+ private readonly container;
7
8
  private game;
8
9
  private renderManager?;
9
10
  private scenes;
@@ -11,7 +12,7 @@ export declare class SceneManager {
11
12
  private openingSceneName;
12
13
  private sceneToLoad;
13
14
  currentSceneName: string;
14
- constructor(game: Game, renderManager?: IRenderManager);
15
+ constructor(container: Container, game: Game, renderManager?: IRenderManager);
15
16
  getCurrentScene<T extends Scene>(): T;
16
17
  addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
17
18
  loadOpeningScene(): void;