angry-pixel 1.2.0 → 1.2.2

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.
@@ -0,0 +1,68 @@
1
+ import { RenderComponent } from "../../core/Component";
2
+ import { Rotation, Vector2 } from "angry-pixel-math";
3
+ import { Slice } from "angry-pixel-2d-renderer";
4
+ export interface VideoRendererOptions {
5
+ video: HTMLVideoElement;
6
+ width?: number;
7
+ height?: number;
8
+ offset?: Vector2;
9
+ rotation?: Rotation;
10
+ flipHorizontal?: boolean;
11
+ flipVertical?: boolean;
12
+ opacity?: number;
13
+ maskColor?: string;
14
+ maskColorMix?: number;
15
+ tintColor?: string;
16
+ layer?: string;
17
+ slice?: Slice;
18
+ volume?: number;
19
+ loop?: boolean;
20
+ }
21
+ export declare class VideoRenderer extends RenderComponent {
22
+ video: HTMLVideoElement;
23
+ width: number;
24
+ height: number;
25
+ offset: Vector2;
26
+ flipHorizontal: boolean;
27
+ flipVertical: boolean;
28
+ rotation: Rotation;
29
+ opacity: number;
30
+ maskColor: string;
31
+ maskColorMix: number;
32
+ tintColor: string;
33
+ layer: string;
34
+ slice?: Slice;
35
+ private renderData;
36
+ private innerPosition;
37
+ private scaledOffset;
38
+ private _loop;
39
+ private _volume;
40
+ private _playing;
41
+ private _paused;
42
+ set volume(volume: number);
43
+ get volume(): number;
44
+ set loop(loop: boolean);
45
+ get loop(): boolean;
46
+ get playing(): boolean;
47
+ get paused(): boolean;
48
+ protected init(config: VideoRendererOptions): void;
49
+ /**
50
+ * Play the loaded video
51
+ */
52
+ play(): void;
53
+ /**
54
+ * Stop playing the current video
55
+ */
56
+ stop(): void;
57
+ /**
58
+ * Plause the current video
59
+ */
60
+ pause(): void;
61
+ private videoEventHandler;
62
+ private userInputEventHandler;
63
+ protected update(): void;
64
+ private calculateRenderPosition;
65
+ private translateRenderPosition;
66
+ protected onActiveChange(): void;
67
+ protected onDestroy(): void;
68
+ }
@@ -5,7 +5,6 @@ import { GameActor } from "./GameActor";
5
5
  import { Container } from "../utils/Container";
6
6
  export type ComponentClass<T extends Component = Component> = new (container: Container, gameObject: GameObject, name?: string) => T;
7
7
  export declare abstract class Component extends GameActor {
8
- readonly id: string;
9
8
  readonly name: string;
10
9
  readonly gameObject: GameObject;
11
10
  readonly allowMultiple: boolean;
@@ -5,9 +5,9 @@ import { Scene } from "./Scene";
5
5
  import { GameActor, InitOptions } from "./GameActor";
6
6
  import { Container } from "../utils/Container";
7
7
  export declare const LAYER_DEFAULT = "Default";
8
- export type GameObjectClass<T extends GameObject = GameObject> = new (container: Container, name?: string, parent?: GameObject) => T;
8
+ export type GameObjectClass<T extends GameObject = GameObject> = new (container: Container, id: number, name?: string, parent?: GameObject) => T;
9
9
  export declare class GameObject extends GameActor {
10
- readonly id: string;
10
+ readonly id: number;
11
11
  readonly name: string;
12
12
  tag: string;
13
13
  layer: string;
@@ -18,7 +18,7 @@ export declare class GameObject extends GameActor {
18
18
  private components;
19
19
  private activeComponentsCache;
20
20
  private activeChildrenCache;
21
- constructor(container: Container, name?: string, parent?: GameObject);
21
+ constructor(container: Container, id: number, name?: string, parent?: GameObject);
22
22
  get active(): boolean;
23
23
  set active(active: boolean);
24
24
  get parent(): GameObject | null;
@@ -23,6 +23,11 @@ export declare class AssetManagerFacade {
23
23
  * @returns The created fontFace element
24
24
  */
25
25
  static loadFont(family: string, url: string): FontFace;
26
+ /**
27
+ * @param url The url of the video file
28
+ * @returns The created video element
29
+ */
30
+ static loadVideo(url: string): HTMLVideoElement;
26
31
  /**
27
32
  * @param url The url of the image element to find
28
33
  * @returns the found image element
@@ -38,4 +43,9 @@ export declare class AssetManagerFacade {
38
43
  * @returns The found audio element
39
44
  */
40
45
  static getFont(family: string): FontFace;
46
+ /**
47
+ * @param url The url of the video element to find
48
+ * @returns The found video element
49
+ */
50
+ static getVideo(url: string): HTMLVideoElement;
41
51
  }
@@ -2,16 +2,19 @@ import { IRenderManager } from "angry-pixel-2d-renderer";
2
2
  export declare enum AssetType {
3
3
  Image = "Image",
4
4
  Audio = "Audio",
5
- Font = "Font"
5
+ Font = "Font",
6
+ Video = "Video"
6
7
  }
7
8
  export interface IAssetManager {
8
9
  getAssetsLoaded(): boolean;
9
10
  loadImage(url: string, preloadTexture?: boolean): HTMLImageElement;
10
11
  loadAudio(url: string): HTMLAudioElement;
11
12
  loadFont(family: string, url: string): FontFace;
13
+ loadVideo(url: string): HTMLVideoElement;
12
14
  getImage(url: string): HTMLImageElement;
13
15
  getAudio(url: string): HTMLAudioElement;
14
16
  getFont(family: string): FontFace;
17
+ getVideo(url: string): HTMLVideoElement;
15
18
  }
16
19
  export declare class AssetManager implements IAssetManager {
17
20
  private readonly renderManager;
@@ -21,8 +24,10 @@ export declare class AssetManager implements IAssetManager {
21
24
  loadImage(url: string, preloadTexture?: boolean): HTMLImageElement;
22
25
  loadAudio(url: string): HTMLAudioElement;
23
26
  loadFont(family: string, url: string): FontFace;
27
+ loadVideo(url: string): HTMLVideoElement;
24
28
  getImage(url: string): HTMLImageElement;
25
29
  getAudio(url: string): HTMLAudioElement;
26
30
  getFont(family: string): FontFace;
31
+ getVideo(url: string): HTMLVideoElement;
27
32
  private createAsset;
28
33
  }
@@ -4,7 +4,7 @@ import { Container } from "../../utils/Container";
4
4
  export interface IGameObjectManager {
5
5
  addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, parent?: GameObject, name?: string): T;
6
6
  findGameObjects<T extends GameObject>(gameObjectClass?: GameObjectClass<T>): T[];
7
- findGameObjectById<T extends GameObject>(id: string): T;
7
+ findGameObjectById<T extends GameObject>(id: number): T;
8
8
  findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
9
9
  findGameObject<T extends GameObject>(name: string): T;
10
10
  findGameObject<T extends GameObject>(filter: GameObjectClass<T> | string): T;
@@ -22,7 +22,7 @@ export declare class GameObjectManager implements IGameObjectManager {
22
22
  constructor(container: Container);
23
23
  addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, parent?: GameObject, name?: string): T;
24
24
  findGameObjects<T extends GameObject>(gameObjectClass?: GameObjectClass<T>): T[];
25
- findGameObjectById<T extends GameObject>(id: string): T;
25
+ findGameObjectById<T extends GameObject>(id: number): T;
26
26
  findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
27
27
  findGameObject<T extends GameObject>(name: string): T;
28
28
  findGameObjectsByParent<T extends GameObject>(parent: GameObject): T[];