angry-pixel 1.1.1 → 1.1.3
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 +8 -4
- package/lib/component/AudioPlayer.d.ts +6 -4
- package/lib/component/Button.d.ts +42 -0
- package/lib/component/Camera.d.ts +1 -2
- package/lib/component/RigidBody.d.ts +5 -4
- package/lib/component/Transform.d.ts +4 -4
- package/lib/component/collider/BallCollider.d.ts +3 -2
- package/lib/component/collider/BoxCollider.d.ts +3 -2
- package/lib/component/collider/Collider.d.ts +6 -1
- package/lib/component/collider/EdgeCollider.d.ts +7 -4
- package/lib/component/collider/PolygonCollider.d.ts +7 -4
- package/lib/component/collider/TilemapCollider.d.ts +3 -2
- package/lib/component/rendering/MaskRenderer.d.ts +3 -2
- package/lib/component/rendering/SpriteRenderer.d.ts +6 -5
- package/lib/component/rendering/TextRenderer.d.ts +3 -2
- package/lib/component/rendering/tilemap/CsvTilemapRenderer.d.ts +6 -6
- package/lib/component/rendering/tilemap/TileData.d.ts +9 -6
- package/lib/component/rendering/tilemap/TiledTilemapRenderer.d.ts +10 -5
- package/lib/component/rendering/tilemap/TilemapRenderer.d.ts +9 -7
- package/lib/core/Component.d.ts +41 -86
- package/lib/core/Game.d.ts +14 -15
- package/lib/core/GameActor.d.ts +95 -0
- package/lib/core/GameObject.d.ts +69 -88
- package/lib/core/Scene.d.ts +6 -65
- package/lib/core/facades/GameObjectManagerFacade.d.ts +41 -25
- package/lib/core/facades/TimeManagerFacade.d.ts +1 -0
- package/lib/core/managers/AssetManager.d.ts +5 -2
- package/lib/core/managers/GameObjectManager.d.ts +11 -10
- package/lib/core/managers/HeadlessIterationManager.d.ts +29 -0
- package/lib/core/managers/IterationManager copy.d.ts +42 -0
- package/lib/core/managers/IterationManager.d.ts +19 -7
- package/lib/core/managers/IterationManagerOld.d.ts +42 -0
- package/lib/core/managers/SceneManager.d.ts +5 -4
- package/lib/core/managers/TimeManager.d.ts +10 -6
- package/lib/core/managers/headless/HeadlessIterationManager.d.ts +29 -0
- package/lib/core/managers/headless/HeadlessRenderManager.d.ts +10 -0
- package/lib/core/managers/iteration/BrowserIterationManager.d.ts +35 -0
- package/lib/core/managers/iteration/FrameEvent.d.ts +13 -0
- package/lib/core/managers/iteration/HeadlessIterationManager.d.ts +29 -0
- package/lib/core/managers/iteration/IIterationManager.d.ts +7 -0
- package/lib/gameObject/GameCamera.d.ts +2 -2
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/input/GamepadController.d.ts +16 -4
- package/lib/math/Rectangle.d.ts +9 -2
- package/lib/math/Utils.d.ts +8 -2
- package/lib/physics/collision/CollisionManager.d.ts +7 -3
- package/lib/physics/collision/resolver/AABBResolver.d.ts +2 -2
- package/lib/physics/collision/resolver/SatResolver.d.ts +1 -2
- package/lib/physics/rigodBody/RigidBodyData.d.ts +2 -1
- package/lib/physics/rigodBody/RigidBodyManager.d.ts +4 -1
- package/lib/rendering/RenderManager.d.ts +8 -1
- package/lib/rendering/renderData/TextRenderData.d.ts +1 -1
- package/package.json +1 -1
package/lib/core/Component.d.ts
CHANGED
|
@@ -1,130 +1,85 @@
|
|
|
1
|
-
import { GameObjectFactory, GameObjectManager } from "./managers/GameObjectManager";
|
|
2
1
|
import { GameObject } from "./GameObject";
|
|
3
2
|
import { Scene } from "./Scene";
|
|
4
3
|
import { FrameEvent } from "./managers/IterationManager";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { GameActor } from "./GameActor";
|
|
5
|
+
export declare type ComponentClass<T extends Component = Component> = new (gameObject: GameObject, name?: string) => T;
|
|
6
|
+
export declare abstract class Component extends GameActor {
|
|
7
|
+
private readonly sceneManager;
|
|
8
8
|
readonly id: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
allowMultiple: boolean;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly gameObject: GameObject;
|
|
11
|
+
readonly allowMultiple: boolean;
|
|
13
12
|
private _active;
|
|
14
|
-
|
|
15
|
-
protected get updateEvent(): FrameEvent;
|
|
13
|
+
constructor(gameObject: GameObject, name?: string);
|
|
16
14
|
get active(): boolean;
|
|
17
|
-
|
|
18
|
-
dispatch(event: FrameEvent): void;
|
|
19
|
-
/**
|
|
20
|
-
* This method is called only once.
|
|
21
|
-
* Recommended for GameObject cration.
|
|
22
|
-
*/
|
|
23
|
-
protected init(): void;
|
|
24
|
-
/**
|
|
25
|
-
* This method is called only once.
|
|
26
|
-
*/
|
|
27
|
-
protected start(): void;
|
|
28
|
-
/**
|
|
29
|
-
* This method is called on every frame.
|
|
30
|
-
*/
|
|
31
|
-
protected update(): void;
|
|
32
|
-
/**
|
|
33
|
-
* This method is called before the component is destroyed.
|
|
34
|
-
*/
|
|
35
|
-
protected destroy(): void;
|
|
15
|
+
set active(active: boolean);
|
|
36
16
|
/**
|
|
37
17
|
* This method is called when the active state changes.
|
|
38
18
|
*/
|
|
39
|
-
protected
|
|
19
|
+
protected onActiveChange(): void;
|
|
40
20
|
/**
|
|
41
21
|
* @returns The current loaded scene
|
|
42
22
|
*/
|
|
43
23
|
protected getCurrentScene<T extends Scene>(): T;
|
|
44
24
|
/**
|
|
45
|
-
* @
|
|
46
|
-
* @param name The name of the game object, this must not be used by another game object
|
|
47
|
-
* @returns The added game object
|
|
48
|
-
*/
|
|
49
|
-
protected addGameObject<T extends GameObject>(gameObjectFactory: GameObjectFactory, name: string): T;
|
|
50
|
-
/**
|
|
51
|
-
* @param name The name of the component to find
|
|
52
|
-
* @returns The found component
|
|
53
|
-
*/
|
|
54
|
-
protected getComponentByName<T extends Component>(name: string): T;
|
|
55
|
-
/**
|
|
56
|
-
* @param type The type of the component to find
|
|
57
|
-
* @returns The found component
|
|
25
|
+
* @returns The GameObject to which this component is attached
|
|
58
26
|
*/
|
|
59
|
-
protected
|
|
27
|
+
protected getGameObject<T extends GameObject>(): T;
|
|
60
28
|
/**
|
|
61
|
-
*
|
|
29
|
+
* Returns all the components in the game object.
|
|
62
30
|
* @returns The found components
|
|
63
31
|
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @param name The name of the game object to find
|
|
67
|
-
* @returns The found game object
|
|
68
|
-
*/
|
|
69
|
-
protected findGameObjectByName<T extends GameObject>(name: string): T;
|
|
32
|
+
getComponents(): Component[];
|
|
70
33
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @
|
|
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
|
|
73
37
|
*/
|
|
74
|
-
|
|
38
|
+
getComponents<T extends Component>(componentClass: ComponentClass<T>): T[];
|
|
75
39
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
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
|
|
78
43
|
*/
|
|
79
|
-
|
|
44
|
+
getComponent<T extends Component>(componentClass: ComponentClass<T>): T;
|
|
80
45
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param name The name of the
|
|
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
|
|
83
49
|
*/
|
|
84
|
-
|
|
50
|
+
getComponent<T extends Component>(name: string): T;
|
|
85
51
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @param
|
|
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
|
|
88
55
|
*/
|
|
89
|
-
|
|
56
|
+
hasComponent<T extends Component>(componentClass: ComponentClass<T>): boolean;
|
|
90
57
|
/**
|
|
91
58
|
* @param name The name of the component to find
|
|
92
|
-
* @returns
|
|
93
|
-
*/
|
|
94
|
-
hasComponentOfName(name: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* @param type The type of the component to find
|
|
97
|
-
* @returns TRUE or FALSE
|
|
98
|
-
*/
|
|
99
|
-
hasComponentOfType(type: string): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* @param name The name of the component to remove
|
|
102
|
-
*/
|
|
103
|
-
removeComponentByName(name: string): void;
|
|
104
|
-
/**
|
|
105
|
-
* @param type The tyepe of the component to remove
|
|
59
|
+
* @returns boolean
|
|
106
60
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
61
|
+
hasComponent(name: string): boolean;
|
|
62
|
+
removeComponent(component: Component): void;
|
|
63
|
+
protected _destroy(): void;
|
|
109
64
|
}
|
|
110
65
|
export declare abstract class EngineComponent extends Component {
|
|
111
|
-
protected
|
|
66
|
+
protected readonly updateEvent: FrameEvent;
|
|
112
67
|
}
|
|
113
68
|
export declare abstract class ColliderComponent extends Component {
|
|
114
|
-
protected
|
|
69
|
+
protected readonly updateEvent: FrameEvent;
|
|
115
70
|
}
|
|
116
71
|
export declare abstract class PhysicsComponent extends Component {
|
|
117
|
-
protected
|
|
72
|
+
protected readonly updateEvent: FrameEvent;
|
|
118
73
|
}
|
|
119
74
|
export declare abstract class TransformComponent extends Component {
|
|
120
|
-
protected
|
|
75
|
+
protected readonly updateEvent: FrameEvent;
|
|
121
76
|
}
|
|
122
77
|
export declare abstract class PreRenderComponent extends Component {
|
|
123
|
-
protected
|
|
78
|
+
protected readonly updateEvent: FrameEvent;
|
|
124
79
|
}
|
|
125
80
|
export declare abstract class CameraComponent extends Component {
|
|
126
|
-
protected
|
|
81
|
+
protected readonly updateEvent: FrameEvent;
|
|
127
82
|
}
|
|
128
83
|
export declare abstract class RenderComponent extends Component {
|
|
129
|
-
protected
|
|
84
|
+
protected readonly updateEvent: FrameEvent;
|
|
130
85
|
}
|
package/lib/core/Game.d.ts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SceneClass } from "../core/managers/SceneManager";
|
|
2
2
|
import { Container } from "../utils/Container";
|
|
3
3
|
import { Rectangle } from "../math/Rectangle";
|
|
4
4
|
import { Vector2 } from "../math/Vector2";
|
|
5
|
+
import { CollisionMatrix } from "../physics/collision/CollisionManager";
|
|
6
|
+
import { InitOptions } from "./GameActor";
|
|
5
7
|
export declare const container: Container;
|
|
6
8
|
export interface GameConfig {
|
|
7
|
-
containerNode
|
|
9
|
+
containerNode?: HTMLElement | null;
|
|
8
10
|
gameWidth?: number;
|
|
9
11
|
gameHeight?: number;
|
|
10
12
|
debugEnabled?: boolean;
|
|
11
13
|
canvasColor?: string;
|
|
12
14
|
physicsFramerate?: number;
|
|
13
15
|
spriteDefaultScale?: Vector2 | null;
|
|
16
|
+
headless?: boolean;
|
|
14
17
|
collisions?: {
|
|
15
18
|
method?: CollisionMethodConfig;
|
|
16
19
|
quadTreeBounds?: Rectangle | null;
|
|
17
20
|
quadMaxLevel?: number;
|
|
18
21
|
collidersPerQuad?: number;
|
|
22
|
+
collisionMatrix?: CollisionMatrix;
|
|
19
23
|
};
|
|
20
24
|
}
|
|
21
25
|
export declare enum CollisionMethodConfig {
|
|
@@ -24,12 +28,8 @@ export declare enum CollisionMethodConfig {
|
|
|
24
28
|
}
|
|
25
29
|
export declare class Game {
|
|
26
30
|
private sceneManager;
|
|
27
|
-
private renderManager;
|
|
28
31
|
private iterationManager;
|
|
29
32
|
private _config;
|
|
30
|
-
private _running;
|
|
31
|
-
private _stop;
|
|
32
|
-
private frameRequestId;
|
|
33
33
|
constructor(config: GameConfig);
|
|
34
34
|
private setupManagers;
|
|
35
35
|
/**
|
|
@@ -43,11 +43,12 @@ export declare class Game {
|
|
|
43
43
|
/**
|
|
44
44
|
* Add a scene to the game
|
|
45
45
|
*
|
|
46
|
+
* @param sceneClass the class of the scene
|
|
46
47
|
* @param name The name of the scene
|
|
47
|
-
* @param
|
|
48
|
-
* @param openingScene If this is the opening scene, set TRUE, FALSE instead
|
|
48
|
+
* @param options [optional] This options will be passed to the init method
|
|
49
|
+
* @param openingScene [default FALSE] If this is the opening scene, set TRUE, FALSE instead
|
|
49
50
|
*/
|
|
50
|
-
addScene(name: string,
|
|
51
|
+
addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
|
|
51
52
|
/**
|
|
52
53
|
* Run the game
|
|
53
54
|
*/
|
|
@@ -56,14 +57,12 @@ export declare class Game {
|
|
|
56
57
|
* Stop the game
|
|
57
58
|
*/
|
|
58
59
|
stop(): void;
|
|
59
|
-
private gameLoop;
|
|
60
60
|
/**
|
|
61
|
-
* Pauses the game
|
|
61
|
+
* Pauses the game
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
pause(): void;
|
|
64
64
|
/**
|
|
65
|
-
* Resumes the paused game
|
|
65
|
+
* Resumes the paused game
|
|
66
66
|
*/
|
|
67
|
-
|
|
68
|
-
private requestAnimationFrame;
|
|
67
|
+
resume(): void;
|
|
69
68
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { GameObject, GameObjectClass } from "./GameObject";
|
|
2
|
+
import { GameObjectManager } from "./managers/GameObjectManager";
|
|
3
|
+
import { FrameEvent } from "./managers/IterationManager";
|
|
4
|
+
export interface InitOptions {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class GameActor {
|
|
8
|
+
protected readonly gameObjectManager: GameObjectManager;
|
|
9
|
+
protected readonly updateEvent: FrameEvent;
|
|
10
|
+
private started;
|
|
11
|
+
dispatch(event: FrameEvent, options?: InitOptions): void;
|
|
12
|
+
/**
|
|
13
|
+
* This method is called after instantiation (recommended for the creation of game objects).
|
|
14
|
+
*/
|
|
15
|
+
protected init?(options?: InitOptions): void;
|
|
16
|
+
/**
|
|
17
|
+
* This method is called only once on the first available frame.
|
|
18
|
+
*/
|
|
19
|
+
protected start?(): void;
|
|
20
|
+
/**
|
|
21
|
+
* This method is called on every frame.
|
|
22
|
+
*/
|
|
23
|
+
protected update?(): void;
|
|
24
|
+
/**
|
|
25
|
+
* This method is called before destruction.
|
|
26
|
+
*/
|
|
27
|
+
protected onDestroy?(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Adds a new game object to the scene.
|
|
30
|
+
* @param gameObjectClass The game object class
|
|
31
|
+
* @returns The added game object
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
|
|
35
|
+
/**
|
|
36
|
+
* Adds a new game object to the scene.
|
|
37
|
+
* @param gameObjectClass The game object class
|
|
38
|
+
* @param name The name of the game object
|
|
39
|
+
* @returns The added game object
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, name: string): T;
|
|
43
|
+
/**
|
|
44
|
+
* Adds a new game object to the scene.
|
|
45
|
+
* @param gameObjectClass The game object class
|
|
46
|
+
* @param options This options will be passed to the init method
|
|
47
|
+
* @returns The added game object
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options: InitOptions): T;
|
|
51
|
+
/**
|
|
52
|
+
* Adds a new game object to the scene.
|
|
53
|
+
* @param gameObjectClass The game object class
|
|
54
|
+
* @param options [optional] This options will be passed to the init method
|
|
55
|
+
* @param name [optional] The name of the game object
|
|
56
|
+
* @returns The added game object
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions | string, name?: string): T;
|
|
60
|
+
/**
|
|
61
|
+
* Returns all the game objects in the scene.
|
|
62
|
+
* @returns The found game objects
|
|
63
|
+
*/
|
|
64
|
+
protected findGameObjects(): GameObject[];
|
|
65
|
+
/**
|
|
66
|
+
* Returns a collection of found game objects for the given class
|
|
67
|
+
* @param gameObjectClass The game object class to find
|
|
68
|
+
* @returns The found game objects
|
|
69
|
+
*/
|
|
70
|
+
protected findGameObjects<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T[];
|
|
71
|
+
/**
|
|
72
|
+
* Returns the first game object found for the given class, or undefined otherwise.
|
|
73
|
+
* @param gameObjectClass The game object class to find
|
|
74
|
+
* @returns The found game object
|
|
75
|
+
*/
|
|
76
|
+
protected findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the first game object found for the given name, or undefined otherwise.
|
|
79
|
+
* @param name The name of the game object to find
|
|
80
|
+
* @returns The found game object
|
|
81
|
+
*/
|
|
82
|
+
protected findGameObject<T extends GameObject>(name: string): T;
|
|
83
|
+
/**
|
|
84
|
+
* Returns a collection of game objects found for the given tag
|
|
85
|
+
* @param tag The tag of the game objects to find
|
|
86
|
+
* @returns The found game objects
|
|
87
|
+
*/
|
|
88
|
+
protected findGameObjectsByTag<T extends GameObject>(tag: string): T[];
|
|
89
|
+
/**
|
|
90
|
+
* Destroy the given game object
|
|
91
|
+
* @param gameObject The game object to destory
|
|
92
|
+
*/
|
|
93
|
+
protected destroyGameObject(gameObject: GameObject): void;
|
|
94
|
+
protected abstract _destroy(): void;
|
|
95
|
+
}
|
package/lib/core/GameObject.d.ts
CHANGED
|
@@ -1,133 +1,124 @@
|
|
|
1
|
-
import { Component } from "./Component";
|
|
1
|
+
import { Component, ComponentClass } from "./Component";
|
|
2
2
|
import { Transform } from "../component/Transform";
|
|
3
3
|
import { RigidBody } from "../component/RigidBody";
|
|
4
|
-
import { GameObjectFactory } from "../core/managers/GameObjectManager";
|
|
5
4
|
import { Scene } from "./Scene";
|
|
6
|
-
import {
|
|
5
|
+
import { GameActor, InitOptions } from "./GameActor";
|
|
7
6
|
export declare const LAYER_DEFAULT = "Default";
|
|
8
|
-
export declare type
|
|
9
|
-
export declare class GameObject {
|
|
7
|
+
export declare type GameObjectClass<T extends GameObject = GameObject> = new (name?: string, parent?: GameObject) => T;
|
|
8
|
+
export declare class GameObject extends GameActor {
|
|
10
9
|
readonly id: string;
|
|
11
|
-
name: string;
|
|
10
|
+
readonly name: string;
|
|
12
11
|
tag: string;
|
|
13
12
|
layer: string;
|
|
14
13
|
ui: boolean;
|
|
15
14
|
keep: boolean;
|
|
16
|
-
private _active;
|
|
17
15
|
private _parent;
|
|
18
|
-
private
|
|
16
|
+
private _active;
|
|
19
17
|
private sceneManager;
|
|
20
|
-
private gameObjectManager;
|
|
21
18
|
private components;
|
|
22
|
-
|
|
19
|
+
private activeComponentsCache;
|
|
20
|
+
private activeChildrenCache;
|
|
21
|
+
constructor(name?: string, parent?: GameObject);
|
|
23
22
|
get active(): boolean;
|
|
24
|
-
|
|
25
|
-
get transform(): Transform;
|
|
26
|
-
get rigidBody(): RigidBody;
|
|
23
|
+
set active(active: boolean);
|
|
27
24
|
get parent(): GameObject | null;
|
|
28
25
|
set parent(parent: GameObject | null);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
protected init(): void;
|
|
35
|
-
/**
|
|
36
|
-
* This method is called only once.
|
|
37
|
-
*/
|
|
38
|
-
protected start(): void;
|
|
39
|
-
/**
|
|
40
|
-
* This method is called on every frame.
|
|
41
|
-
*/
|
|
42
|
-
protected update(): void;
|
|
26
|
+
private updateComponentsActiveStatus;
|
|
27
|
+
private updateChildrenActiveStatus;
|
|
28
|
+
get transform(): Transform;
|
|
29
|
+
get rigidBody(): RigidBody;
|
|
43
30
|
/**
|
|
44
|
-
* This method is called
|
|
31
|
+
* This method is called when the active state changes.
|
|
45
32
|
*/
|
|
46
|
-
protected
|
|
33
|
+
protected onActiveChange(): void;
|
|
47
34
|
/**
|
|
48
35
|
* @returns The current loaded scene
|
|
49
36
|
*/
|
|
50
37
|
protected getCurrentScene<T extends Scene>(): T;
|
|
51
38
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param
|
|
54
|
-
* @returns The added
|
|
55
|
-
*/
|
|
56
|
-
protected addGameObject<T extends GameObject>(gameObjectFactory: GameObjectFactory, name: string): T;
|
|
57
|
-
/**
|
|
58
|
-
* @param name The name of the game object to find
|
|
59
|
-
* @returns The found game object
|
|
39
|
+
* Add a component to the game obejct
|
|
40
|
+
* @param componentClass The class of the component
|
|
41
|
+
* @returns The added component
|
|
60
42
|
*/
|
|
61
|
-
|
|
43
|
+
addComponent<ComponentType extends Component = Component>(componentClass: ComponentClass<ComponentType>): ComponentType;
|
|
62
44
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
45
|
+
* Add a component to the game obejct
|
|
46
|
+
* @param componentClass The class of the component
|
|
47
|
+
* @param options The options passed to the init method of the component
|
|
48
|
+
* @returns The added component
|
|
65
49
|
*/
|
|
66
|
-
|
|
50
|
+
addComponent<ComponentType extends Component = Component, OptionsType extends InitOptions = InitOptions>(componentClass: ComponentClass<ComponentType>, options: OptionsType): ComponentType;
|
|
67
51
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
52
|
+
* Add a component to the game obejct
|
|
53
|
+
* @param componentClass The class of the component
|
|
54
|
+
* @param name The name of the component
|
|
55
|
+
* @returns The added component
|
|
70
56
|
*/
|
|
71
|
-
|
|
57
|
+
addComponent<ComponentType extends Component = Component>(componentClass: ComponentClass<ComponentType>, name: string): ComponentType;
|
|
72
58
|
/**
|
|
73
|
-
* Add a
|
|
74
|
-
*
|
|
75
|
-
* @param
|
|
76
|
-
* @param name
|
|
59
|
+
* Add a component to the game obejct
|
|
60
|
+
* @param componentClass The class of the component
|
|
61
|
+
* @param options The options passed to the init method of the component
|
|
62
|
+
* @param name The name of the component
|
|
77
63
|
* @returns The added component
|
|
78
64
|
*/
|
|
79
|
-
addComponent<
|
|
65
|
+
addComponent<ComponentType extends Component = Component, OptionsType extends InitOptions = InitOptions>(componentClass: ComponentClass<ComponentType>, options: OptionsType, name: string): ComponentType;
|
|
80
66
|
private checkMultipleComponent;
|
|
81
67
|
/**
|
|
82
|
-
*
|
|
68
|
+
* Returns all the components in the game object.
|
|
69
|
+
* @returns The found components
|
|
83
70
|
*/
|
|
84
71
|
getComponents(): Component[];
|
|
85
72
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
*/
|
|
89
|
-
getComponentByName<T extends Component>(name: string): T;
|
|
90
|
-
/**
|
|
91
|
-
* @param type The type of the component to find
|
|
92
|
-
* @returns The found component
|
|
93
|
-
*/
|
|
94
|
-
getComponentByType<T extends Component>(type: string): T;
|
|
95
|
-
/**
|
|
96
|
-
* @param type The type of the components to find
|
|
73
|
+
* Returns all the components for the given class in the game object.
|
|
74
|
+
* @param componentClass The class of the components
|
|
97
75
|
* @returns The found components
|
|
98
76
|
*/
|
|
99
|
-
|
|
77
|
+
getComponents<T extends Component>(componentClass: ComponentClass<T>): T[];
|
|
100
78
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @
|
|
79
|
+
* Returns the first component found for the given class, or undefined otherwise.
|
|
80
|
+
* @param componentClass The class of the component
|
|
81
|
+
* @returns The found component
|
|
103
82
|
*/
|
|
104
|
-
|
|
83
|
+
getComponent<T extends Component>(componentClass: ComponentClass<T>): T;
|
|
105
84
|
/**
|
|
106
|
-
*
|
|
107
|
-
* @
|
|
85
|
+
* Returns the first component found for the given name, or undefined otherwise.
|
|
86
|
+
* @param name The name of the component
|
|
87
|
+
* @returns The found component
|
|
108
88
|
*/
|
|
109
|
-
|
|
89
|
+
getComponent<T extends Component>(name: string): T;
|
|
110
90
|
/**
|
|
111
|
-
*
|
|
91
|
+
* Returns TRUE if the game object has a component for the given class, or FALSE otherwise
|
|
92
|
+
* @param componentClass The class of the component to find
|
|
93
|
+
* @returns boolean
|
|
112
94
|
*/
|
|
113
|
-
|
|
95
|
+
hasComponent<T extends Component>(componentClass: ComponentClass<T>): boolean;
|
|
114
96
|
/**
|
|
115
|
-
* @param
|
|
97
|
+
* @param name The name of the component to find
|
|
98
|
+
* @returns boolean
|
|
116
99
|
*/
|
|
117
|
-
|
|
100
|
+
hasComponent(name: string): boolean;
|
|
101
|
+
removeComponent(component: Component): void;
|
|
118
102
|
/**
|
|
119
103
|
* Add a child game object.
|
|
120
|
-
*
|
|
121
|
-
* @param
|
|
122
|
-
* @param name The name of the
|
|
104
|
+
* @param gameObjectClass The class of the child game object
|
|
105
|
+
* @param options [optional] This options will be passed to the init method
|
|
106
|
+
* @param name [optional] The name of the game object
|
|
123
107
|
* @returns The added child game object
|
|
124
108
|
*/
|
|
125
|
-
addChild<T extends GameObject>(
|
|
109
|
+
addChild<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, name?: string): T;
|
|
126
110
|
/**
|
|
127
111
|
* @returns The children game objects
|
|
128
112
|
*/
|
|
129
|
-
getChildren():
|
|
113
|
+
getChildren<T extends GameObject>(): T[];
|
|
114
|
+
/**
|
|
115
|
+
* Returns the first child found for the given class, or undefined otherwise.
|
|
116
|
+
* @param gameObjectClass The class of the child game object to find
|
|
117
|
+
* @returns The found child game object
|
|
118
|
+
*/
|
|
119
|
+
getChild<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
|
|
130
120
|
/**
|
|
121
|
+
* Returns the first child found for the given name, or undefined otherwise.
|
|
131
122
|
* @param name The name of the child game object to find
|
|
132
123
|
* @returns The found child game object
|
|
133
124
|
*/
|
|
@@ -136,16 +127,6 @@ export declare class GameObject {
|
|
|
136
127
|
* Destroy all the children game objects
|
|
137
128
|
*/
|
|
138
129
|
destroyChildren(): void;
|
|
139
|
-
|
|
140
|
-
* Destroy one game objects by its name
|
|
141
|
-
* @param name The name of the game object
|
|
142
|
-
*/
|
|
143
|
-
destroyGameObjectByName(name: string): void;
|
|
144
|
-
/**
|
|
145
|
-
* Destroy the game objects
|
|
146
|
-
* @param gameObject The game object to destory
|
|
147
|
-
*/
|
|
148
|
-
destroyGameObject(gameObject: GameObject): void;
|
|
149
|
-
private _destroy;
|
|
130
|
+
protected _destroy(): void;
|
|
150
131
|
private destroyComponents;
|
|
151
132
|
}
|
package/lib/core/Scene.d.ts
CHANGED
|
@@ -1,69 +1,10 @@
|
|
|
1
1
|
import { GameCamera } from "../gameObject/GameCamera";
|
|
2
2
|
import { Game } from "./Game";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
private readonly gameObjectManager;
|
|
9
|
-
game: Game;
|
|
10
|
-
name: string;
|
|
11
|
-
private started;
|
|
12
|
-
constructor();
|
|
3
|
+
import { GameActor } from "./GameActor";
|
|
4
|
+
export declare class Scene extends GameActor {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly game: Game;
|
|
7
|
+
constructor(name: string, game: Game);
|
|
13
8
|
get gameCamera(): GameCamera;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* This method is called only once.
|
|
17
|
-
* Recommended for GameObject cration.
|
|
18
|
-
*/
|
|
19
|
-
protected init(): void;
|
|
20
|
-
/**
|
|
21
|
-
* This method is called only once.
|
|
22
|
-
*/
|
|
23
|
-
protected start(): void;
|
|
24
|
-
/**
|
|
25
|
-
* This method is called on every frame.
|
|
26
|
-
*/
|
|
27
|
-
protected update(): void;
|
|
28
|
-
/**
|
|
29
|
-
* This method is called before the scene is destroyed.
|
|
30
|
-
*/
|
|
31
|
-
protected destroy(): void;
|
|
32
|
-
/**
|
|
33
|
-
* @param gameObjectFactory The factory function for the game object
|
|
34
|
-
* @param name The name of the game object, this must not be used by another game object
|
|
35
|
-
* @returns The added game object
|
|
36
|
-
*/
|
|
37
|
-
protected addGameObject<T extends GameObject>(gameObjectFactory: GameObjectFactory, name: string): T;
|
|
38
|
-
/**
|
|
39
|
-
* @returns The all the loaded game objects
|
|
40
|
-
*/
|
|
41
|
-
protected getGameObjects(): GameObject[];
|
|
42
|
-
/**
|
|
43
|
-
* @param name The name of the game object to find
|
|
44
|
-
* @returns The found game object
|
|
45
|
-
*/
|
|
46
|
-
protected findGameObjectByName<T extends GameObject>(name: string): T;
|
|
47
|
-
/**
|
|
48
|
-
* @param tag The tag of the game objects to find
|
|
49
|
-
* @returns The found game objects
|
|
50
|
-
*/
|
|
51
|
-
protected findGameObjectsByTag(tag: string): GameObject[];
|
|
52
|
-
/**
|
|
53
|
-
* @param tag The tag of the game object to find
|
|
54
|
-
* @returns The found game object
|
|
55
|
-
*/
|
|
56
|
-
protected findGameObjectByTag<T extends GameObject>(tag: string): T;
|
|
57
|
-
/**
|
|
58
|
-
* Destroy one game objects by its name
|
|
59
|
-
* @param name The name of the game object
|
|
60
|
-
*/
|
|
61
|
-
protected destroyGameObjectByName(name: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* Destroy the game objects
|
|
64
|
-
*
|
|
65
|
-
* @param gameObject The game object to destory
|
|
66
|
-
*/
|
|
67
|
-
protected destroyGameObject(gameObject: GameObject): void;
|
|
68
|
-
private _destroy;
|
|
9
|
+
protected _destroy(): void;
|
|
69
10
|
}
|