angry-pixel 1.1.10 → 1.1.12

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,7 +1,18 @@
1
1
  import { EngineComponent } from "../core/Component";
2
2
  import { SpriteRenderer } from "./rendering/SpriteRenderer";
3
- import { Animation } from "./Animation";
3
+ import { Sprite } from "./Sprite";
4
4
  import { InitOptions } from "../core/GameActor";
5
+ export interface AnimationConfig {
6
+ sprites: Sprite[];
7
+ loop: boolean;
8
+ framerate: number;
9
+ }
10
+ export declare class Animation {
11
+ sprites: Sprite[];
12
+ framerate: number;
13
+ loop: boolean;
14
+ constructor(config: AnimationConfig);
15
+ }
5
16
  export interface AnimatorOptions extends InitOptions {
6
17
  spriteRenderer: SpriteRenderer;
7
18
  }
@@ -1,22 +1,19 @@
1
1
  import { EngineComponent } from "../core/Component";
2
2
  import { InitOptions } from "../core/GameActor";
3
3
  export interface AudioPlayerOptions extends InitOptions {
4
- audioSource?: HTMLAudioElement;
5
4
  volume?: number;
6
5
  loop?: boolean;
7
- playOnStart?: boolean;
8
6
  }
9
7
  export declare class AudioPlayer extends EngineComponent {
10
8
  readonly allowMultiple: boolean;
11
9
  private audioContext;
12
10
  private tracks;
11
+ private audioSourceCache;
13
12
  private _audioSource;
14
13
  private _volume;
15
14
  private _loop;
16
- private playOnStart;
17
15
  private _playing;
18
16
  private _paused;
19
- set audioSource(audioSource: HTMLAudioElement);
20
17
  get audioSource(): HTMLAudioElement;
21
18
  set volume(volume: number);
22
19
  get volume(): number;
@@ -24,11 +21,36 @@ export declare class AudioPlayer extends EngineComponent {
24
21
  get loop(): boolean;
25
22
  get playing(): boolean;
26
23
  get paused(): boolean;
27
- protected init({ audioSource, loop, volume, playOnStart }?: AudioPlayerOptions): void;
28
- protected start(): void;
24
+ protected init({ loop, volume }?: AudioPlayerOptions): void;
25
+ /**
26
+ * Play once the given audio source
27
+ * @param audioSource
28
+ * @param volume optional
29
+ */
29
30
  playClip(audioSource: HTMLAudioElement, volume?: number): void;
31
+ /**
32
+ * Add a new audio source
33
+ * @param audioSource
34
+ */
35
+ addAudioSource(audioSource: HTMLAudioElement, name?: string): void;
36
+ /**
37
+ * Load the given audio source (if there is other audio source playing, it will stop)
38
+ * @param audioSourceName
39
+ * @param loop optional
40
+ * @param volume optional
41
+ */
42
+ loadAudioSource(audioSourceName: string, loop?: boolean, volume?: number): void;
43
+ /**
44
+ * Play the loaded audio source
45
+ */
30
46
  play(): void;
47
+ /**
48
+ * Stop playing the current audio source
49
+ */
31
50
  stop(): void;
51
+ /**
52
+ * Plause the current audio source
53
+ */
32
54
  pause(): void;
33
55
  private audioEventHandler;
34
56
  private userInputEventHandler;
@@ -61,6 +61,7 @@ export declare abstract class Component extends GameActor {
61
61
  hasComponent(name: string): boolean;
62
62
  removeComponent(component: Component): void;
63
63
  protected _destroy(): void;
64
+ protected _stopGame(): void;
64
65
  }
65
66
  export declare abstract class EngineComponent extends Component {
66
67
  protected readonly updateEvent: FrameEvent;
@@ -95,4 +95,5 @@ export declare abstract class GameActor {
95
95
  */
96
96
  protected destroyGameObject(gameObject: GameObject): void;
97
97
  protected abstract _destroy(): void;
98
+ protected abstract _stopGame(): void;
98
99
  }
@@ -129,4 +129,5 @@ export declare class GameObject extends GameActor {
129
129
  destroyChildren(): void;
130
130
  protected _destroy(): void;
131
131
  private destroyComponents;
132
+ protected _stopGame(): void;
132
133
  }
@@ -9,4 +9,5 @@ export declare class Scene extends GameActor {
9
9
  constructor(container: Container, name: string, game: Game);
10
10
  get gameCamera(): GameCamera;
11
11
  protected _destroy(): void;
12
+ protected _stopGame(): void;
12
13
  }
@@ -14,7 +14,7 @@ export declare class GameObjectManager {
14
14
  findGameObjectByParent<T extends GameObject>(parent: GameObject, gameObjectClass: GameObjectClass<T>): T;
15
15
  findGameObjectByParent<T extends GameObject>(parent: GameObject, name: string): T;
16
16
  findGameObjectsByTag<T extends GameObject>(tag: string): T[];
17
- destroyAllGameObjects(): void;
17
+ destroyAllGameObjects(ignoreKeep?: boolean): void;
18
18
  destroyGameObject(gameObject: GameObject): void;
19
19
  private destroy;
20
20
  private destroyChildren;
@@ -15,7 +15,8 @@ export declare enum FrameEvent {
15
15
  UpdatePreRender = 7,
16
16
  UpdateCamera = 8,
17
17
  UpdateRender = 9,
18
- Destroy = 10
18
+ Destroy = 10,
19
+ StopGame = 11
19
20
  }
20
21
  export interface IIterationManager {
21
22
  running: boolean;
@@ -18,4 +18,5 @@ export declare class SceneManager {
18
18
  update(): void;
19
19
  private _loadScene;
20
20
  unloadCurrentScene(): void;
21
+ stopGame(): void;
21
22
  }