angry-pixel 1.1.13 → 1.1.14
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/component/Animator.d.ts +33 -33
- package/lib/component/AudioPlayer.d.ts +59 -59
- package/lib/component/Button.d.ts +42 -42
- package/lib/component/Camera.d.ts +21 -21
- package/lib/component/RigidBody.d.ts +23 -23
- package/lib/component/Sprite.d.ts +22 -22
- package/lib/component/Transform.d.ts +30 -30
- package/lib/component/collider/BallCollider.d.ts +25 -25
- package/lib/component/collider/BoxCollider.d.ts +33 -33
- package/lib/component/collider/Collider.d.ts +35 -35
- package/lib/component/collider/EdgeCollider.d.ts +29 -29
- package/lib/component/collider/PolygonCollider.d.ts +40 -40
- package/lib/component/collider/TilemapCollider.d.ts +29 -29
- package/lib/component/rendering/MaskRenderer.d.ts +28 -28
- package/lib/component/rendering/SpriteRenderer.d.ts +44 -44
- package/lib/component/rendering/TextRenderer.d.ts +47 -47
- package/lib/component/rendering/TiledTilemapRenderer.d.ts +79 -79
- package/lib/component/rendering/TilemapRenderer.d.ts +55 -55
- package/lib/core/Component.d.ts +86 -86
- package/lib/core/Game.d.ts +44 -44
- package/lib/core/GameActor.d.ts +99 -99
- package/lib/core/GameConfig.d.ts +18 -18
- package/lib/core/GameObject.d.ts +133 -133
- package/lib/core/Scene.d.ts +13 -13
- package/lib/core/facades/AssetManagerFacade.d.ts +41 -41
- package/lib/core/facades/DomManagerFacade.d.ts +8 -8
- package/lib/core/facades/GameObjectManagerFacade.d.ts +70 -70
- package/lib/core/facades/InputManagerFacade.d.ts +13 -13
- package/lib/core/facades/SceneManagerFacade.d.ts +18 -18
- package/lib/core/facades/TimeManagerFacade.d.ts +11 -11
- package/lib/core/ioc/Config.d.ts +3 -3
- package/lib/core/managers/AssetManager.d.ts +28 -28
- package/lib/core/managers/DomManager.d.ts +9 -9
- package/lib/core/managers/GameObjectManager.d.ts +21 -21
- package/lib/core/managers/HeadlessIterationManager.d.ts +29 -29
- package/lib/core/managers/IterationManager.d.ts +56 -56
- package/lib/core/managers/SceneManager.d.ts +22 -22
- package/lib/core/managers/TimeManager.d.ts +24 -24
- package/lib/gameObject/GameCamera.d.ts +16 -16
- package/lib/gameObject/SpacePointer.d.ts +8 -8
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +38 -38
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/input/GamepadController.d.ts +51 -63
- package/lib/input/InputManager.d.ts +12 -12
- package/lib/input/KeyboardController.d.ts +12 -12
- package/lib/input/MouseController.d.ts +21 -21
- package/lib/input/TouchController.d.ts +13 -13
- package/lib/utils/Container.d.ts +12 -12
- package/lib/utils/Exception.d.ts +4 -4
- package/lib/utils/UUID.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { TilemapOrientation } from "angry-pixel-2d-renderer";
|
|
2
|
-
import { Vector2 } from "angry-pixel-math";
|
|
3
|
-
import { RenderComponent } from "../../core/Component";
|
|
4
|
-
export { TilemapOrientation };
|
|
5
|
-
export interface Tileset {
|
|
6
|
-
image: HTMLImageElement;
|
|
7
|
-
width: number;
|
|
8
|
-
tileWidth: number;
|
|
9
|
-
tileHeight: number;
|
|
10
|
-
margin?: Vector2;
|
|
11
|
-
spacing?: Vector2;
|
|
12
|
-
}
|
|
13
|
-
export interface TilemapRendererOptions {
|
|
14
|
-
tiles: string;
|
|
15
|
-
tileset: Tileset;
|
|
16
|
-
width: number;
|
|
17
|
-
tileWidth: number;
|
|
18
|
-
tileHeight: number;
|
|
19
|
-
layer?: string;
|
|
20
|
-
orientation?: TilemapOrientation;
|
|
21
|
-
alpha?: number;
|
|
22
|
-
tintColor?: string;
|
|
23
|
-
smooth?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface ITilemapRenderer {
|
|
26
|
-
tiles: number[];
|
|
27
|
-
width: number;
|
|
28
|
-
height: number;
|
|
29
|
-
tileWidth: number;
|
|
30
|
-
tileHeight: number;
|
|
31
|
-
orientation: TilemapOrientation;
|
|
32
|
-
realWidth: number;
|
|
33
|
-
realHeight: number;
|
|
34
|
-
}
|
|
35
|
-
export declare class TilemapRenderer extends RenderComponent implements ITilemapRenderer {
|
|
36
|
-
private renderManager;
|
|
37
|
-
tiles: number[];
|
|
38
|
-
width: number;
|
|
39
|
-
height: number;
|
|
40
|
-
tileWidth: number;
|
|
41
|
-
tileHeight: number;
|
|
42
|
-
tintColor: string;
|
|
43
|
-
alpha: number;
|
|
44
|
-
orientation: TilemapOrientation;
|
|
45
|
-
private tileset;
|
|
46
|
-
private renderData;
|
|
47
|
-
private layer;
|
|
48
|
-
private scaledTileWidth;
|
|
49
|
-
private scaledTileHeight;
|
|
50
|
-
realWidth: number;
|
|
51
|
-
realHeight: number;
|
|
52
|
-
protected init({ tiles, tileset, tileWidth, tileHeight, width, layer, orientation, alpha, tintColor, smooth, }: TilemapRendererOptions): void;
|
|
53
|
-
protected update(): void;
|
|
54
|
-
private updateRenderData;
|
|
55
|
-
}
|
|
1
|
+
import { TilemapOrientation } from "angry-pixel-2d-renderer";
|
|
2
|
+
import { Vector2 } from "angry-pixel-math";
|
|
3
|
+
import { RenderComponent } from "../../core/Component";
|
|
4
|
+
export { TilemapOrientation };
|
|
5
|
+
export interface Tileset {
|
|
6
|
+
image: HTMLImageElement;
|
|
7
|
+
width: number;
|
|
8
|
+
tileWidth: number;
|
|
9
|
+
tileHeight: number;
|
|
10
|
+
margin?: Vector2;
|
|
11
|
+
spacing?: Vector2;
|
|
12
|
+
}
|
|
13
|
+
export interface TilemapRendererOptions {
|
|
14
|
+
tiles: string;
|
|
15
|
+
tileset: Tileset;
|
|
16
|
+
width: number;
|
|
17
|
+
tileWidth: number;
|
|
18
|
+
tileHeight: number;
|
|
19
|
+
layer?: string;
|
|
20
|
+
orientation?: TilemapOrientation;
|
|
21
|
+
alpha?: number;
|
|
22
|
+
tintColor?: string;
|
|
23
|
+
smooth?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ITilemapRenderer {
|
|
26
|
+
tiles: number[];
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
tileWidth: number;
|
|
30
|
+
tileHeight: number;
|
|
31
|
+
orientation: TilemapOrientation;
|
|
32
|
+
realWidth: number;
|
|
33
|
+
realHeight: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class TilemapRenderer extends RenderComponent implements ITilemapRenderer {
|
|
36
|
+
private renderManager;
|
|
37
|
+
tiles: number[];
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
tileWidth: number;
|
|
41
|
+
tileHeight: number;
|
|
42
|
+
tintColor: string;
|
|
43
|
+
alpha: number;
|
|
44
|
+
orientation: TilemapOrientation;
|
|
45
|
+
private tileset;
|
|
46
|
+
private renderData;
|
|
47
|
+
private layer;
|
|
48
|
+
private scaledTileWidth;
|
|
49
|
+
private scaledTileHeight;
|
|
50
|
+
realWidth: number;
|
|
51
|
+
realHeight: number;
|
|
52
|
+
protected init({ tiles, tileset, tileWidth, tileHeight, width, layer, orientation, alpha, tintColor, smooth, }: TilemapRendererOptions): void;
|
|
53
|
+
protected update(): void;
|
|
54
|
+
private updateRenderData;
|
|
55
|
+
}
|
package/lib/core/Component.d.ts
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { GameObject } from "./GameObject";
|
|
2
|
-
import { Scene } from "./Scene";
|
|
3
|
-
import { FrameEvent } from "./managers/IterationManager";
|
|
4
|
-
import { GameActor } from "./GameActor";
|
|
5
|
-
import { Container } from "../utils/Container";
|
|
6
|
-
export type ComponentClass<T extends Component = Component> = new (container: Container, gameObject: GameObject, name?: string) => T;
|
|
7
|
-
export declare abstract class Component extends GameActor {
|
|
8
|
-
readonly id: string;
|
|
9
|
-
readonly name: string;
|
|
10
|
-
readonly gameObject: GameObject;
|
|
11
|
-
readonly allowMultiple: boolean;
|
|
12
|
-
private _active;
|
|
13
|
-
constructor(container: Container, gameObject: GameObject, name?: string);
|
|
14
|
-
get active(): boolean;
|
|
15
|
-
set active(active: boolean);
|
|
16
|
-
/**
|
|
17
|
-
* This method is called when the active state changes.
|
|
18
|
-
*/
|
|
19
|
-
protected onActiveChange(): void;
|
|
20
|
-
/**
|
|
21
|
-
* @returns The current loaded scene
|
|
22
|
-
*/
|
|
23
|
-
protected getCurrentScene<T extends Scene>(): T;
|
|
24
|
-
/**
|
|
25
|
-
* @returns The GameObject to which this component is attached
|
|
26
|
-
*/
|
|
27
|
-
protected getGameObject<T extends GameObject>(): T;
|
|
28
|
-
/**
|
|
29
|
-
* Returns all the components in the game object.
|
|
30
|
-
* @returns The found components
|
|
31
|
-
*/
|
|
32
|
-
getComponents(): Component[];
|
|
33
|
-
/**
|
|
34
|
-
* Returns all the components for the given class in the game object.
|
|
35
|
-
* @param componentClass The class of the components
|
|
36
|
-
* @returns The found components
|
|
37
|
-
*/
|
|
38
|
-
getComponents<T extends Component>(componentClass: ComponentClass<T>): T[];
|
|
39
|
-
/**
|
|
40
|
-
* Returns the first component found for the given class, or undefined otherwise.
|
|
41
|
-
* @param componentClass The class of the component
|
|
42
|
-
* @returns The found component
|
|
43
|
-
*/
|
|
44
|
-
getComponent<T extends Component>(componentClass: ComponentClass<T>): T;
|
|
45
|
-
/**
|
|
46
|
-
* Returns the first component found for the given name, or undefined otherwise.
|
|
47
|
-
* @param name The name of the component
|
|
48
|
-
* @returns The found component
|
|
49
|
-
*/
|
|
50
|
-
getComponent<T extends Component>(name: string): T;
|
|
51
|
-
/**
|
|
52
|
-
* Returns TRUE if the game object has a component for the given class, or FALSE otherwise
|
|
53
|
-
* @param componentClass The class of the component to find
|
|
54
|
-
* @returns boolean
|
|
55
|
-
*/
|
|
56
|
-
hasComponent<T extends Component>(componentClass: ComponentClass<T>): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* @param name The name of the component to find
|
|
59
|
-
* @returns boolean
|
|
60
|
-
*/
|
|
61
|
-
hasComponent(name: string): boolean;
|
|
62
|
-
removeComponent(component: Component): void;
|
|
63
|
-
protected _destroy(): void;
|
|
64
|
-
protected _stopGame(): void;
|
|
65
|
-
}
|
|
66
|
-
export declare abstract class EngineComponent extends Component {
|
|
67
|
-
protected readonly updateEvent: FrameEvent;
|
|
68
|
-
}
|
|
69
|
-
export declare abstract class ColliderComponent extends Component {
|
|
70
|
-
protected readonly updateEvent: FrameEvent;
|
|
71
|
-
}
|
|
72
|
-
export declare abstract class PhysicsComponent extends Component {
|
|
73
|
-
protected readonly updateEvent: FrameEvent;
|
|
74
|
-
}
|
|
75
|
-
export declare abstract class TransformComponent extends Component {
|
|
76
|
-
protected readonly updateEvent: FrameEvent;
|
|
77
|
-
}
|
|
78
|
-
export declare abstract class PreRenderComponent extends Component {
|
|
79
|
-
protected readonly updateEvent: FrameEvent;
|
|
80
|
-
}
|
|
81
|
-
export declare abstract class CameraComponent extends Component {
|
|
82
|
-
protected readonly updateEvent: FrameEvent;
|
|
83
|
-
}
|
|
84
|
-
export declare abstract class RenderComponent extends Component {
|
|
85
|
-
protected readonly updateEvent: FrameEvent;
|
|
86
|
-
}
|
|
1
|
+
import { GameObject } from "./GameObject";
|
|
2
|
+
import { Scene } from "./Scene";
|
|
3
|
+
import { FrameEvent } from "./managers/IterationManager";
|
|
4
|
+
import { GameActor } from "./GameActor";
|
|
5
|
+
import { Container } from "../utils/Container";
|
|
6
|
+
export type ComponentClass<T extends Component = Component> = new (container: Container, gameObject: GameObject, name?: string) => T;
|
|
7
|
+
export declare abstract class Component extends GameActor {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly gameObject: GameObject;
|
|
11
|
+
readonly allowMultiple: boolean;
|
|
12
|
+
private _active;
|
|
13
|
+
constructor(container: Container, gameObject: GameObject, name?: string);
|
|
14
|
+
get active(): boolean;
|
|
15
|
+
set active(active: boolean);
|
|
16
|
+
/**
|
|
17
|
+
* This method is called when the active state changes.
|
|
18
|
+
*/
|
|
19
|
+
protected onActiveChange(): void;
|
|
20
|
+
/**
|
|
21
|
+
* @returns The current loaded scene
|
|
22
|
+
*/
|
|
23
|
+
protected getCurrentScene<T extends Scene>(): T;
|
|
24
|
+
/**
|
|
25
|
+
* @returns The GameObject to which this component is attached
|
|
26
|
+
*/
|
|
27
|
+
protected getGameObject<T extends GameObject>(): T;
|
|
28
|
+
/**
|
|
29
|
+
* Returns all the components in the game object.
|
|
30
|
+
* @returns The found components
|
|
31
|
+
*/
|
|
32
|
+
getComponents(): Component[];
|
|
33
|
+
/**
|
|
34
|
+
* Returns all the components for the given class in the game object.
|
|
35
|
+
* @param componentClass The class of the components
|
|
36
|
+
* @returns The found components
|
|
37
|
+
*/
|
|
38
|
+
getComponents<T extends Component>(componentClass: ComponentClass<T>): T[];
|
|
39
|
+
/**
|
|
40
|
+
* Returns the first component found for the given class, or undefined otherwise.
|
|
41
|
+
* @param componentClass The class of the component
|
|
42
|
+
* @returns The found component
|
|
43
|
+
*/
|
|
44
|
+
getComponent<T extends Component>(componentClass: ComponentClass<T>): T;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the first component found for the given name, or undefined otherwise.
|
|
47
|
+
* @param name The name of the component
|
|
48
|
+
* @returns The found component
|
|
49
|
+
*/
|
|
50
|
+
getComponent<T extends Component>(name: string): T;
|
|
51
|
+
/**
|
|
52
|
+
* Returns TRUE if the game object has a component for the given class, or FALSE otherwise
|
|
53
|
+
* @param componentClass The class of the component to find
|
|
54
|
+
* @returns boolean
|
|
55
|
+
*/
|
|
56
|
+
hasComponent<T extends Component>(componentClass: ComponentClass<T>): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @param name The name of the component to find
|
|
59
|
+
* @returns boolean
|
|
60
|
+
*/
|
|
61
|
+
hasComponent(name: string): boolean;
|
|
62
|
+
removeComponent(component: Component): void;
|
|
63
|
+
protected _destroy(): void;
|
|
64
|
+
protected _stopGame(): void;
|
|
65
|
+
}
|
|
66
|
+
export declare abstract class EngineComponent extends Component {
|
|
67
|
+
protected readonly updateEvent: FrameEvent;
|
|
68
|
+
}
|
|
69
|
+
export declare abstract class ColliderComponent extends Component {
|
|
70
|
+
protected readonly updateEvent: FrameEvent;
|
|
71
|
+
}
|
|
72
|
+
export declare abstract class PhysicsComponent extends Component {
|
|
73
|
+
protected readonly updateEvent: FrameEvent;
|
|
74
|
+
}
|
|
75
|
+
export declare abstract class TransformComponent extends Component {
|
|
76
|
+
protected readonly updateEvent: FrameEvent;
|
|
77
|
+
}
|
|
78
|
+
export declare abstract class PreRenderComponent extends Component {
|
|
79
|
+
protected readonly updateEvent: FrameEvent;
|
|
80
|
+
}
|
|
81
|
+
export declare abstract class CameraComponent extends Component {
|
|
82
|
+
protected readonly updateEvent: FrameEvent;
|
|
83
|
+
}
|
|
84
|
+
export declare abstract class RenderComponent extends Component {
|
|
85
|
+
protected readonly updateEvent: FrameEvent;
|
|
86
|
+
}
|
package/lib/core/Game.d.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { InitOptions } from "./GameActor";
|
|
2
|
-
import { GameConfig } from "./GameConfig";
|
|
3
|
-
import { SceneClass } from "./Scene";
|
|
4
|
-
export declare class Game {
|
|
5
|
-
private readonly container;
|
|
6
|
-
private sceneManager;
|
|
7
|
-
private iterationManager;
|
|
8
|
-
private _config;
|
|
9
|
-
constructor(config: GameConfig);
|
|
10
|
-
private setupManagers;
|
|
11
|
-
/**
|
|
12
|
-
* @returns GameConfig
|
|
13
|
-
*/
|
|
14
|
-
get config(): GameConfig;
|
|
15
|
-
/**
|
|
16
|
-
* @returns running
|
|
17
|
-
*/
|
|
18
|
-
get running(): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Add a scene to the game
|
|
21
|
-
*
|
|
22
|
-
* @param sceneClass the class of the scene
|
|
23
|
-
* @param name The name of the scene
|
|
24
|
-
* @param options [optional] This options will be passed to the init method
|
|
25
|
-
* @param openingScene [default FALSE] If this is the opening scene, set TRUE, FALSE instead
|
|
26
|
-
*/
|
|
27
|
-
addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
|
|
28
|
-
/**
|
|
29
|
-
* Run the game
|
|
30
|
-
*/
|
|
31
|
-
run(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Stop the game
|
|
34
|
-
*/
|
|
35
|
-
stop(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Pauses the game
|
|
38
|
-
*/
|
|
39
|
-
pause(): void;
|
|
40
|
-
/**
|
|
41
|
-
* Resumes the paused game
|
|
42
|
-
*/
|
|
43
|
-
resume(): void;
|
|
44
|
-
}
|
|
1
|
+
import { InitOptions } from "./GameActor";
|
|
2
|
+
import { GameConfig } from "./GameConfig";
|
|
3
|
+
import { SceneClass } from "./Scene";
|
|
4
|
+
export declare class Game {
|
|
5
|
+
private readonly container;
|
|
6
|
+
private sceneManager;
|
|
7
|
+
private iterationManager;
|
|
8
|
+
private _config;
|
|
9
|
+
constructor(config: GameConfig);
|
|
10
|
+
private setupManagers;
|
|
11
|
+
/**
|
|
12
|
+
* @returns GameConfig
|
|
13
|
+
*/
|
|
14
|
+
get config(): GameConfig;
|
|
15
|
+
/**
|
|
16
|
+
* @returns running
|
|
17
|
+
*/
|
|
18
|
+
get running(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Add a scene to the game
|
|
21
|
+
*
|
|
22
|
+
* @param sceneClass the class of the scene
|
|
23
|
+
* @param name The name of the scene
|
|
24
|
+
* @param options [optional] This options will be passed to the init method
|
|
25
|
+
* @param openingScene [default FALSE] If this is the opening scene, set TRUE, FALSE instead
|
|
26
|
+
*/
|
|
27
|
+
addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
|
|
28
|
+
/**
|
|
29
|
+
* Run the game
|
|
30
|
+
*/
|
|
31
|
+
run(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Stop the game
|
|
34
|
+
*/
|
|
35
|
+
stop(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Pauses the game
|
|
38
|
+
*/
|
|
39
|
+
pause(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Resumes the paused game
|
|
42
|
+
*/
|
|
43
|
+
resume(): void;
|
|
44
|
+
}
|
package/lib/core/GameActor.d.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { Container } from "../utils/Container";
|
|
2
|
-
import { GameObject, GameObjectClass } from "./GameObject";
|
|
3
|
-
import { GameObjectManager } from "./managers/GameObjectManager";
|
|
4
|
-
import { FrameEvent } from "./managers/IterationManager";
|
|
5
|
-
export interface InitOptions {
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
}
|
|
8
|
-
export declare abstract class GameActor {
|
|
9
|
-
protected readonly gameObjectManager: GameObjectManager;
|
|
10
|
-
protected readonly updateEvent: FrameEvent;
|
|
11
|
-
protected readonly container: Container;
|
|
12
|
-
private started;
|
|
13
|
-
constructor(container: Container);
|
|
14
|
-
dispatch(event: FrameEvent, options?: InitOptions): void;
|
|
15
|
-
/**
|
|
16
|
-
* This method is called after instantiation (recommended for the creation of game objects).
|
|
17
|
-
*/
|
|
18
|
-
protected init?(options?: InitOptions): void;
|
|
19
|
-
/**
|
|
20
|
-
* This method is called only once on the first available frame.
|
|
21
|
-
*/
|
|
22
|
-
protected start?(): void;
|
|
23
|
-
/**
|
|
24
|
-
* This method is called on every frame.
|
|
25
|
-
*/
|
|
26
|
-
protected update?(): void;
|
|
27
|
-
/**
|
|
28
|
-
* This method is called before destruction.
|
|
29
|
-
*/
|
|
30
|
-
protected onDestroy?(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Adds a new game object to the scene.
|
|
33
|
-
* @param gameObjectClass The game object class
|
|
34
|
-
* @returns The added game object
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
|
|
38
|
-
/**
|
|
39
|
-
* Adds a new game object to the scene.
|
|
40
|
-
* @param gameObjectClass The game object class
|
|
41
|
-
* @param name The name of the game object
|
|
42
|
-
* @returns The added game object
|
|
43
|
-
* @returns
|
|
44
|
-
*/
|
|
45
|
-
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, name: string): T;
|
|
46
|
-
/**
|
|
47
|
-
* Adds a new game object to the scene.
|
|
48
|
-
* @param gameObjectClass The game object class
|
|
49
|
-
* @param options This options will be passed to the init method
|
|
50
|
-
* @returns The added game object
|
|
51
|
-
* @returns
|
|
52
|
-
*/
|
|
53
|
-
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options: InitOptions): T;
|
|
54
|
-
/**
|
|
55
|
-
* Adds a new game object to the scene.
|
|
56
|
-
* @param gameObjectClass The game object class
|
|
57
|
-
* @param options [optional] This options will be passed to the init method
|
|
58
|
-
* @param name [optional] The name of the game object
|
|
59
|
-
* @returns The added game object
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions | string, name?: string): T;
|
|
63
|
-
/**
|
|
64
|
-
* Returns all the game objects in the scene.
|
|
65
|
-
* @returns The found game objects
|
|
66
|
-
*/
|
|
67
|
-
protected findGameObjects(): GameObject[];
|
|
68
|
-
/**
|
|
69
|
-
* Returns a collection of found game objects for the given class
|
|
70
|
-
* @param gameObjectClass The game object class to find
|
|
71
|
-
* @returns The found game objects
|
|
72
|
-
*/
|
|
73
|
-
protected findGameObjects<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T[];
|
|
74
|
-
/**
|
|
75
|
-
* Returns the first game object found for the given class, or undefined otherwise.
|
|
76
|
-
* @param gameObjectClass The game object class to find
|
|
77
|
-
* @returns The found game object
|
|
78
|
-
*/
|
|
79
|
-
protected findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
|
|
80
|
-
/**
|
|
81
|
-
* Returns the first game object found for the given name, or undefined otherwise.
|
|
82
|
-
* @param name The name of the game object to find
|
|
83
|
-
* @returns The found game object
|
|
84
|
-
*/
|
|
85
|
-
protected findGameObject<T extends GameObject>(name: string): T;
|
|
86
|
-
/**
|
|
87
|
-
* Returns a collection of game objects found for the given tag
|
|
88
|
-
* @param tag The tag of the game objects to find
|
|
89
|
-
* @returns The found game objects
|
|
90
|
-
*/
|
|
91
|
-
protected findGameObjectsByTag<T extends GameObject>(tag: string): T[];
|
|
92
|
-
/**
|
|
93
|
-
* Destroy the given game object
|
|
94
|
-
* @param gameObject The game object to destory
|
|
95
|
-
*/
|
|
96
|
-
protected destroyGameObject(gameObject: GameObject): void;
|
|
97
|
-
protected abstract _destroy(): void;
|
|
98
|
-
protected abstract _stopGame(): void;
|
|
99
|
-
}
|
|
1
|
+
import { Container } from "../utils/Container";
|
|
2
|
+
import { GameObject, GameObjectClass } from "./GameObject";
|
|
3
|
+
import { GameObjectManager } from "./managers/GameObjectManager";
|
|
4
|
+
import { FrameEvent } from "./managers/IterationManager";
|
|
5
|
+
export interface InitOptions {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class GameActor {
|
|
9
|
+
protected readonly gameObjectManager: GameObjectManager;
|
|
10
|
+
protected readonly updateEvent: FrameEvent;
|
|
11
|
+
protected readonly container: Container;
|
|
12
|
+
private started;
|
|
13
|
+
constructor(container: Container);
|
|
14
|
+
dispatch(event: FrameEvent, options?: InitOptions): void;
|
|
15
|
+
/**
|
|
16
|
+
* This method is called after instantiation (recommended for the creation of game objects).
|
|
17
|
+
*/
|
|
18
|
+
protected init?(options?: InitOptions): void;
|
|
19
|
+
/**
|
|
20
|
+
* This method is called only once on the first available frame.
|
|
21
|
+
*/
|
|
22
|
+
protected start?(): void;
|
|
23
|
+
/**
|
|
24
|
+
* This method is called on every frame.
|
|
25
|
+
*/
|
|
26
|
+
protected update?(): void;
|
|
27
|
+
/**
|
|
28
|
+
* This method is called before destruction.
|
|
29
|
+
*/
|
|
30
|
+
protected onDestroy?(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Adds a new game object to the scene.
|
|
33
|
+
* @param gameObjectClass The game object class
|
|
34
|
+
* @returns The added game object
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
|
|
38
|
+
/**
|
|
39
|
+
* Adds a new game object to the scene.
|
|
40
|
+
* @param gameObjectClass The game object class
|
|
41
|
+
* @param name The name of the game object
|
|
42
|
+
* @returns The added game object
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, name: string): T;
|
|
46
|
+
/**
|
|
47
|
+
* Adds a new game object to the scene.
|
|
48
|
+
* @param gameObjectClass The game object class
|
|
49
|
+
* @param options This options will be passed to the init method
|
|
50
|
+
* @returns The added game object
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options: InitOptions): T;
|
|
54
|
+
/**
|
|
55
|
+
* Adds a new game object to the scene.
|
|
56
|
+
* @param gameObjectClass The game object class
|
|
57
|
+
* @param options [optional] This options will be passed to the init method
|
|
58
|
+
* @param name [optional] The name of the game object
|
|
59
|
+
* @returns The added game object
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions | string, name?: string): T;
|
|
63
|
+
/**
|
|
64
|
+
* Returns all the game objects in the scene.
|
|
65
|
+
* @returns The found game objects
|
|
66
|
+
*/
|
|
67
|
+
protected findGameObjects(): GameObject[];
|
|
68
|
+
/**
|
|
69
|
+
* Returns a collection of found game objects for the given class
|
|
70
|
+
* @param gameObjectClass The game object class to find
|
|
71
|
+
* @returns The found game objects
|
|
72
|
+
*/
|
|
73
|
+
protected findGameObjects<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T[];
|
|
74
|
+
/**
|
|
75
|
+
* Returns the first game object found for the given class, or undefined otherwise.
|
|
76
|
+
* @param gameObjectClass The game object class to find
|
|
77
|
+
* @returns The found game object
|
|
78
|
+
*/
|
|
79
|
+
protected findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the first game object found for the given name, or undefined otherwise.
|
|
82
|
+
* @param name The name of the game object to find
|
|
83
|
+
* @returns The found game object
|
|
84
|
+
*/
|
|
85
|
+
protected findGameObject<T extends GameObject>(name: string): T;
|
|
86
|
+
/**
|
|
87
|
+
* Returns a collection of game objects found for the given tag
|
|
88
|
+
* @param tag The tag of the game objects to find
|
|
89
|
+
* @returns The found game objects
|
|
90
|
+
*/
|
|
91
|
+
protected findGameObjectsByTag<T extends GameObject>(tag: string): T[];
|
|
92
|
+
/**
|
|
93
|
+
* Destroy the given game object
|
|
94
|
+
* @param gameObject The game object to destory
|
|
95
|
+
*/
|
|
96
|
+
protected destroyGameObject(gameObject: GameObject): void;
|
|
97
|
+
protected abstract _destroy(): void;
|
|
98
|
+
protected abstract _stopGame(): void;
|
|
99
|
+
}
|
package/lib/core/GameConfig.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { BroadPhaseMethods, CollisionMatrix, CollisionMethods } from "angry-pixel-2d-physics";
|
|
2
|
-
import { Rectangle, Vector2 } from "angry-pixel-math";
|
|
3
|
-
export interface GameConfig {
|
|
4
|
-
containerNode?: HTMLElement | null;
|
|
5
|
-
gameWidth?: number;
|
|
6
|
-
gameHeight?: number;
|
|
7
|
-
debugEnabled?: boolean;
|
|
8
|
-
canvasColor?: string;
|
|
9
|
-
physicsFramerate?: number;
|
|
10
|
-
spriteDefaultScale?: Vector2 | null;
|
|
11
|
-
headless?: boolean;
|
|
12
|
-
collisions?: {
|
|
13
|
-
collisionMethod?: CollisionMethods;
|
|
14
|
-
collisionArea?: Rectangle;
|
|
15
|
-
collisionMatrix?: CollisionMatrix;
|
|
16
|
-
collisionBroadPhaseMethod?: BroadPhaseMethods;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
1
|
+
import { BroadPhaseMethods, CollisionMatrix, CollisionMethods } from "angry-pixel-2d-physics";
|
|
2
|
+
import { Rectangle, Vector2 } from "angry-pixel-math";
|
|
3
|
+
export interface GameConfig {
|
|
4
|
+
containerNode?: HTMLElement | null;
|
|
5
|
+
gameWidth?: number;
|
|
6
|
+
gameHeight?: number;
|
|
7
|
+
debugEnabled?: boolean;
|
|
8
|
+
canvasColor?: string;
|
|
9
|
+
physicsFramerate?: number;
|
|
10
|
+
spriteDefaultScale?: Vector2 | null;
|
|
11
|
+
headless?: boolean;
|
|
12
|
+
collisions?: {
|
|
13
|
+
collisionMethod?: CollisionMethods;
|
|
14
|
+
collisionArea?: Rectangle;
|
|
15
|
+
collisionMatrix?: CollisionMatrix;
|
|
16
|
+
collisionBroadPhaseMethod?: BroadPhaseMethods;
|
|
17
|
+
};
|
|
18
|
+
}
|