angry-pixel 1.2.17 → 2.0.1
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/README.md +99 -87
- package/lib/index.cjs.js +1 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +3194 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -8
- package/package.dev.json +0 -32
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,3194 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This type represents a dependency class
|
|
3
|
+
* @public
|
|
4
|
+
* @category Core
|
|
5
|
+
*/
|
|
6
|
+
type DependencyType = {
|
|
7
|
+
new (...args: any[]): any;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* This type represents a dependency name
|
|
11
|
+
* @public
|
|
12
|
+
* @category Core
|
|
13
|
+
*/
|
|
14
|
+
type DependencyName = string | symbol;
|
|
15
|
+
type PropertyKey = string | symbol;
|
|
16
|
+
declare class Container {
|
|
17
|
+
private instances;
|
|
18
|
+
private types;
|
|
19
|
+
add(type: DependencyType, name?: DependencyName): Container;
|
|
20
|
+
set(name: DependencyName, dependency: any): Container;
|
|
21
|
+
get<T>(name: DependencyName): T;
|
|
22
|
+
has(name: DependencyName): boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Decorator to identify a class as an injectable dependency
|
|
26
|
+
* @param name the name to identify the dependency
|
|
27
|
+
* @public
|
|
28
|
+
* @category Decorators
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* @injectable("SomeDependency")
|
|
32
|
+
* class SomeDependency {}
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function injectable(name: DependencyName): (target: DependencyType) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Decorator to identify a property, or constructor argument, as a dependency to be injected
|
|
38
|
+
* @param name the name to identify the dependency
|
|
39
|
+
* @public
|
|
40
|
+
* @category Decorators
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* class SomeClass {
|
|
44
|
+
* private anotherDependency: DependencyType;
|
|
45
|
+
*
|
|
46
|
+
* constructor(@inject("AnotherDependency") anotherDependency: DependencyType) {
|
|
47
|
+
* this.anotherDependency = anotherDependency;
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* class SomeClass {
|
|
54
|
+
* @inject("AnotherDependency") private anotherDependency: DependencyType;
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare function inject(name: DependencyName): (target: any, propertyKey: PropertyKey, parameterIndex?: number) => void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Represents a 2D vector and provides static methods for vector calculations.
|
|
62
|
+
* @category Math
|
|
63
|
+
* @public
|
|
64
|
+
* @example
|
|
65
|
+
* ```js
|
|
66
|
+
* const v1 = new Vector2(2, 1);
|
|
67
|
+
* const v2 = new Vector2(3, 2);
|
|
68
|
+
* const v3 = new Vector2(); // zero vector
|
|
69
|
+
*
|
|
70
|
+
* Vector2.add(v3, v1, v2);
|
|
71
|
+
* v3.x // 5
|
|
72
|
+
* v3.y // 3
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare class Vector2 {
|
|
76
|
+
private _x;
|
|
77
|
+
private _y;
|
|
78
|
+
private _direction;
|
|
79
|
+
constructor(x?: number, y?: number);
|
|
80
|
+
get x(): number;
|
|
81
|
+
set x(x: number);
|
|
82
|
+
get y(): number;
|
|
83
|
+
set y(y: number);
|
|
84
|
+
/**
|
|
85
|
+
* Get the magnitude of the vector
|
|
86
|
+
*
|
|
87
|
+
* @returns The magnitude of the vector
|
|
88
|
+
*/
|
|
89
|
+
get magnitude(): number;
|
|
90
|
+
/**
|
|
91
|
+
* Get the direction as an unit vector
|
|
92
|
+
*
|
|
93
|
+
* @returns The direction vector
|
|
94
|
+
*/
|
|
95
|
+
get direction(): Vector2;
|
|
96
|
+
/**
|
|
97
|
+
* Set the vector
|
|
98
|
+
*
|
|
99
|
+
* @param x The x value
|
|
100
|
+
* @param y The y value
|
|
101
|
+
*/
|
|
102
|
+
set(x: number, y: number): void;
|
|
103
|
+
/**
|
|
104
|
+
* Copy the target vector properties
|
|
105
|
+
*
|
|
106
|
+
* @param vector The vector to copy from
|
|
107
|
+
*/
|
|
108
|
+
copy(vector: Vector2): void;
|
|
109
|
+
/**
|
|
110
|
+
* Compare if two vector are equals
|
|
111
|
+
*
|
|
112
|
+
* @param vector The vector to compare
|
|
113
|
+
* @returns True if the vectors are equals, false if not
|
|
114
|
+
*/
|
|
115
|
+
equals(vector: Vector2): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Colne a vector into a new instace
|
|
118
|
+
*
|
|
119
|
+
* @returns The cloned vector
|
|
120
|
+
*/
|
|
121
|
+
clone(): Vector2;
|
|
122
|
+
/**
|
|
123
|
+
* Get the distance with another vector
|
|
124
|
+
*
|
|
125
|
+
* @param vector The vector to compare
|
|
126
|
+
* @returns The magnitude of the distance
|
|
127
|
+
*/
|
|
128
|
+
distance(vector: Vector2): number;
|
|
129
|
+
/**
|
|
130
|
+
* Calculates a + b
|
|
131
|
+
* @param out The output vector
|
|
132
|
+
* @param a The first operand
|
|
133
|
+
* @param b The second operand
|
|
134
|
+
* @returns The output vector
|
|
135
|
+
* @example
|
|
136
|
+
* ```js
|
|
137
|
+
* const v1 = new Vector2(2, 1);
|
|
138
|
+
* const v2 = new Vector2(3, 2);
|
|
139
|
+
* const v3 = Vector2.add(new Vector2(), v1, v2);
|
|
140
|
+
* v3.x // 5
|
|
141
|
+
* v3.y // 3
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
static add(out: Vector2, a: Vector2, b: Vector2): Vector2;
|
|
145
|
+
/**
|
|
146
|
+
* Calculates a - b
|
|
147
|
+
*
|
|
148
|
+
* @param out The output vector
|
|
149
|
+
* @param a The first operand
|
|
150
|
+
* @param b The second operand
|
|
151
|
+
* @returns The output vector
|
|
152
|
+
* @example
|
|
153
|
+
* ```js
|
|
154
|
+
* const v1 = new Vector2(3, 2);
|
|
155
|
+
* const v2 = new Vector2(2, 1);
|
|
156
|
+
* const v3 = Vector2.subtract(new Vector2(), v1, v2);
|
|
157
|
+
* v3.x // 1
|
|
158
|
+
* v3.y // 1
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
static subtract(out: Vector2, a: Vector2, b: Vector2): Vector2;
|
|
162
|
+
/**
|
|
163
|
+
* Returns the unit vector
|
|
164
|
+
*
|
|
165
|
+
* @param out The output vector
|
|
166
|
+
* @param a The vector to get the unit
|
|
167
|
+
* @returns The output vector
|
|
168
|
+
* @example
|
|
169
|
+
* ```js
|
|
170
|
+
* const v1 = new Vector2(3, 0);
|
|
171
|
+
* const v2 = Vector2.unit(new Vector2(), v1);
|
|
172
|
+
* v2.x // 1
|
|
173
|
+
* v2.y // 0
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
static unit(out: Vector2, a: Vector2): Vector2;
|
|
177
|
+
/**
|
|
178
|
+
* Normalize a vector
|
|
179
|
+
*
|
|
180
|
+
* @param out The output vector
|
|
181
|
+
* @param a The vector to normalize
|
|
182
|
+
* @returns The output vector
|
|
183
|
+
* @example
|
|
184
|
+
* ```js
|
|
185
|
+
* const v1 = new Vector2(0, 2);
|
|
186
|
+
* const v2 = Vector2.normal(new Vector2(), v1);
|
|
187
|
+
* v2.x // -2
|
|
188
|
+
* v2.y // 0
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
static normal(out: Vector2, a: Vector2): Vector2;
|
|
192
|
+
/**
|
|
193
|
+
* Scale a vector
|
|
194
|
+
*
|
|
195
|
+
* @param out The output vector
|
|
196
|
+
* @param a The vector to scale
|
|
197
|
+
* @param scalar The scalar value
|
|
198
|
+
* @returns The output vector
|
|
199
|
+
* @example
|
|
200
|
+
* ```js
|
|
201
|
+
* const v1 = new Vector2(3, 2);
|
|
202
|
+
* const v2 = Vector2.scale(new Vector2(), v1, 2);
|
|
203
|
+
* v2.x // 6
|
|
204
|
+
* v2.y // 4
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
static scale(out: Vector2, a: Vector2, scalar: number): Vector2;
|
|
208
|
+
/**
|
|
209
|
+
* Calculates the dot product of two vectors and returns a scalar value
|
|
210
|
+
*
|
|
211
|
+
* @param a The first operand
|
|
212
|
+
* @param b The second operand
|
|
213
|
+
* @returns The dot product result
|
|
214
|
+
* @example
|
|
215
|
+
* ```js
|
|
216
|
+
* const v1 = new Vector2(3, 2);
|
|
217
|
+
* const v2 = new Vector2(2, 1);
|
|
218
|
+
* Vector2.dot(v1, v2); // 8
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
static dot(a: Vector2, b: Vector2): number;
|
|
222
|
+
/**
|
|
223
|
+
* Calculates the cross product of two vectors and returns a scalar value
|
|
224
|
+
*
|
|
225
|
+
* @param a The first operand
|
|
226
|
+
* @param b The second operand
|
|
227
|
+
* @returns The cross produc result
|
|
228
|
+
* @example
|
|
229
|
+
* ```js
|
|
230
|
+
* const v1 = new Vector2(3, 2);
|
|
231
|
+
* const v2 = new Vector2(2, 1);
|
|
232
|
+
* Vector2.cross(v1, v2); // -1
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
static cross(a: Vector2, b: Vector2): number;
|
|
236
|
+
/**
|
|
237
|
+
* Rounds a vector
|
|
238
|
+
*
|
|
239
|
+
* @param a The vector to round
|
|
240
|
+
* @returns The output vector
|
|
241
|
+
* @example
|
|
242
|
+
* ```js
|
|
243
|
+
* const v1 = new Vector2(3.9, 2.2);
|
|
244
|
+
* const v2 = Vector2.round(new Vector2(), v1);
|
|
245
|
+
* v2.x // 4
|
|
246
|
+
* v2.y // 2
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
static round(out: Vector2, a: Vector2): Vector2;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Represents an axis aligned rectangle
|
|
254
|
+
* @category Math
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
declare class Rectangle {
|
|
258
|
+
width: number;
|
|
259
|
+
height: number;
|
|
260
|
+
private _position;
|
|
261
|
+
private _center;
|
|
262
|
+
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
263
|
+
get x(): number;
|
|
264
|
+
set x(value: number);
|
|
265
|
+
get y(): number;
|
|
266
|
+
set y(value: number);
|
|
267
|
+
get x1(): number;
|
|
268
|
+
get y1(): number;
|
|
269
|
+
get position(): Vector2;
|
|
270
|
+
set position(position: Vector2);
|
|
271
|
+
get center(): Vector2;
|
|
272
|
+
/**
|
|
273
|
+
* Set the rectangle
|
|
274
|
+
*
|
|
275
|
+
* @param x
|
|
276
|
+
* @param y
|
|
277
|
+
* @param width
|
|
278
|
+
* @param height
|
|
279
|
+
*/
|
|
280
|
+
set(x: number, y: number, width: number, height: number): void;
|
|
281
|
+
/**
|
|
282
|
+
* Compare if two rectangles are equals
|
|
283
|
+
*
|
|
284
|
+
* @param rectangle The rectangle to compare
|
|
285
|
+
* @returns TRUE if the rectangles are equals, FALSE if not
|
|
286
|
+
*/
|
|
287
|
+
equals(rectangle: Rectangle): boolean;
|
|
288
|
+
/**
|
|
289
|
+
* Copy the target rectangle properties
|
|
290
|
+
*
|
|
291
|
+
* @param rect The rectangle to copy from
|
|
292
|
+
*/
|
|
293
|
+
copy(rect: Rectangle): void;
|
|
294
|
+
/**
|
|
295
|
+
* Check if the target rectangle is overlapping
|
|
296
|
+
*
|
|
297
|
+
* @param rect The target rectangle
|
|
298
|
+
* @returns TRUE or FALSE
|
|
299
|
+
*/
|
|
300
|
+
overlaps(rect: Rectangle): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Check if the target rectangle is contained
|
|
303
|
+
*
|
|
304
|
+
* @param rect The target rectangle
|
|
305
|
+
* @returns TRUE or FALSE
|
|
306
|
+
*/
|
|
307
|
+
contains(rect: Rectangle): boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Check if the target vector is contained
|
|
310
|
+
*
|
|
311
|
+
* @param vector The target vector
|
|
312
|
+
* @returns TRUE or FALSE
|
|
313
|
+
*/
|
|
314
|
+
contains(vector: Vector2): boolean;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Clamps the given value between the given minimum and maximum values.
|
|
319
|
+
* @category Math
|
|
320
|
+
* @public
|
|
321
|
+
* @param value number to clamp
|
|
322
|
+
* @param min min value
|
|
323
|
+
* @param max max value
|
|
324
|
+
* @returns clamped value
|
|
325
|
+
*/
|
|
326
|
+
declare const clamp: (value: number, min: number, max: number) => number;
|
|
327
|
+
/**
|
|
328
|
+
* Returns a random integer number between the given minimum and maximum values.
|
|
329
|
+
* @category Math
|
|
330
|
+
* @public
|
|
331
|
+
* @param min min value
|
|
332
|
+
* @param max max value
|
|
333
|
+
* @returns the random int value
|
|
334
|
+
*/
|
|
335
|
+
declare const randomInt: (min: number, max: number) => number;
|
|
336
|
+
/**
|
|
337
|
+
* Returns a random float number between the given minimum and maximum values.
|
|
338
|
+
* @category Math
|
|
339
|
+
* @public
|
|
340
|
+
* @param min min value
|
|
341
|
+
* @param max max value
|
|
342
|
+
* @returns the random float value
|
|
343
|
+
*/
|
|
344
|
+
declare const randomFloat: (min: number, max: number, decimals?: number) => number;
|
|
345
|
+
/**
|
|
346
|
+
* Corrects a floating number to a given number of decimal places.
|
|
347
|
+
* @category Math
|
|
348
|
+
* @public
|
|
349
|
+
* @param value the value to round
|
|
350
|
+
* @param decimals the number of decimals
|
|
351
|
+
* @returns the rounded value
|
|
352
|
+
*/
|
|
353
|
+
declare const fixedRound: (value: number, decimals: number) => number;
|
|
354
|
+
/**
|
|
355
|
+
* Generate an array with a range of numbers.
|
|
356
|
+
* @category Math
|
|
357
|
+
* @public
|
|
358
|
+
* @param start the starting value
|
|
359
|
+
* @param end the end value
|
|
360
|
+
* @param steps the steps to move
|
|
361
|
+
* @returns number range
|
|
362
|
+
*/
|
|
363
|
+
declare const range: (start: number, end: number, steps?: number) => number[];
|
|
364
|
+
/**
|
|
365
|
+
* Evaluates whether the given value is between the minimum and the maximum (both inclusive).
|
|
366
|
+
* @category Math
|
|
367
|
+
* @public
|
|
368
|
+
* @param value number to compare
|
|
369
|
+
* @param min min value
|
|
370
|
+
* @param max max value
|
|
371
|
+
* @returns true if the number is between the min and the max, false instead
|
|
372
|
+
*/
|
|
373
|
+
declare const between: (value: number, min: number, max: number) => boolean;
|
|
374
|
+
|
|
375
|
+
/** @internal */
|
|
376
|
+
interface Shape {
|
|
377
|
+
boundingBox: Rectangle;
|
|
378
|
+
collider: number;
|
|
379
|
+
entity: number;
|
|
380
|
+
id: number;
|
|
381
|
+
ignoreCollisionsWithLayers: string[];
|
|
382
|
+
layer: string;
|
|
383
|
+
position: Vector2;
|
|
384
|
+
projectionAxes: Vector2[];
|
|
385
|
+
radius: number;
|
|
386
|
+
rotation: number;
|
|
387
|
+
vertexModel: Vector2[];
|
|
388
|
+
vertices: Vector2[];
|
|
389
|
+
updateCollisions: boolean;
|
|
390
|
+
}
|
|
391
|
+
/** @internal */
|
|
392
|
+
declare class Polygon implements Shape {
|
|
393
|
+
rotation: number;
|
|
394
|
+
boundingBox: Rectangle;
|
|
395
|
+
collider: number;
|
|
396
|
+
entity: number;
|
|
397
|
+
id: number;
|
|
398
|
+
ignoreCollisionsWithLayers: string[];
|
|
399
|
+
layer: string;
|
|
400
|
+
position: Vector2;
|
|
401
|
+
projectionAxes: Vector2[];
|
|
402
|
+
radius: number;
|
|
403
|
+
vertices: Vector2[];
|
|
404
|
+
updateCollisions: boolean;
|
|
405
|
+
private _vertexModel;
|
|
406
|
+
get vertexModel(): Vector2[];
|
|
407
|
+
set vertexModel(vertexModel: Vector2[]);
|
|
408
|
+
constructor(vertexModel: Vector2[], rotation?: number);
|
|
409
|
+
}
|
|
410
|
+
/** @internal */
|
|
411
|
+
declare class Circumference implements Shape {
|
|
412
|
+
radius: number;
|
|
413
|
+
boundingBox: Rectangle;
|
|
414
|
+
collider: number;
|
|
415
|
+
entity: number;
|
|
416
|
+
id: number;
|
|
417
|
+
ignoreCollisionsWithLayers: string[];
|
|
418
|
+
layer: string;
|
|
419
|
+
position: Vector2;
|
|
420
|
+
projectionAxes: Vector2[];
|
|
421
|
+
rotation: number;
|
|
422
|
+
vertexModel: Vector2[];
|
|
423
|
+
vertices: Vector2[];
|
|
424
|
+
updateCollisions: boolean;
|
|
425
|
+
constructor(radius: number);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Broad phase collision methods
|
|
430
|
+
* - QuadTree: Stores the shapes in an incremental quad tree.
|
|
431
|
+
* - SpartialGrid: Stores the shapes in an incremental spartial grid.
|
|
432
|
+
* @category Config
|
|
433
|
+
* @public
|
|
434
|
+
*/
|
|
435
|
+
declare enum BroadPhaseMethods {
|
|
436
|
+
QuadTree = 0,
|
|
437
|
+
SpartialGrid = 1
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Contains information about the collision
|
|
442
|
+
* @public
|
|
443
|
+
* @category Collisions
|
|
444
|
+
*/
|
|
445
|
+
interface CollisionResolution {
|
|
446
|
+
/**
|
|
447
|
+
* Intersection between both colliders expressed in pixels
|
|
448
|
+
* @public
|
|
449
|
+
*/
|
|
450
|
+
penetration: number;
|
|
451
|
+
/**
|
|
452
|
+
* Collision direction
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
455
|
+
direction: Vector2;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Resolution phase collision methods
|
|
460
|
+
* - AABB (axis-aligned bounding box): It only works with axis-aligned rectangles and lines and cimcurferences.
|
|
461
|
+
* - SAT (Separation axis theorem): It works with every type of shape.
|
|
462
|
+
* @category Config
|
|
463
|
+
* @public
|
|
464
|
+
*/
|
|
465
|
+
declare enum CollisionMethods {
|
|
466
|
+
AABB = 0,
|
|
467
|
+
SAT = 1
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Interface implemented by the collider components
|
|
472
|
+
* @public
|
|
473
|
+
* @category Collisions
|
|
474
|
+
*/
|
|
475
|
+
interface Collider {
|
|
476
|
+
/** Ignores collisions with layers in the array */
|
|
477
|
+
ignoreCollisionsWithLayers: string[];
|
|
478
|
+
/** Collision layer*/
|
|
479
|
+
layer: string;
|
|
480
|
+
/** X-Y axis offset */
|
|
481
|
+
offset: Vector2;
|
|
482
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
483
|
+
physics: boolean;
|
|
484
|
+
/** @internal */
|
|
485
|
+
shapes: Shape[];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* This type an unique identifier of an Entity
|
|
490
|
+
* @public
|
|
491
|
+
* @category Core
|
|
492
|
+
*/
|
|
493
|
+
type Entity = number;
|
|
494
|
+
/**
|
|
495
|
+
* This type represents an instance of a component
|
|
496
|
+
* @public
|
|
497
|
+
* @category Core
|
|
498
|
+
*/
|
|
499
|
+
type Component = {
|
|
500
|
+
[key: string]: any;
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* This type represents a component class
|
|
504
|
+
* @public
|
|
505
|
+
* @category Core
|
|
506
|
+
*/
|
|
507
|
+
type ComponentType<T extends Component = Component> = {
|
|
508
|
+
new (...args: any[]): T;
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* This type represents a search result object
|
|
512
|
+
* @public
|
|
513
|
+
* @category Core
|
|
514
|
+
*/
|
|
515
|
+
type SearchResult<T extends Component> = {
|
|
516
|
+
entity: Entity;
|
|
517
|
+
component: T;
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* This type represents a search criteria object
|
|
521
|
+
* @public
|
|
522
|
+
* @category Core
|
|
523
|
+
*/
|
|
524
|
+
type SearchCriteria = {
|
|
525
|
+
[key: string]: any;
|
|
526
|
+
};
|
|
527
|
+
/**
|
|
528
|
+
* The EntityManager manages the entities and components.\
|
|
529
|
+
* It provides the necessary methods for reading and writing entities and components.
|
|
530
|
+
* @public
|
|
531
|
+
* @category Core
|
|
532
|
+
*/
|
|
533
|
+
declare class EntityManager {
|
|
534
|
+
private lastEntityId;
|
|
535
|
+
private lastComponentTypeId;
|
|
536
|
+
private components;
|
|
537
|
+
private disabledEntities;
|
|
538
|
+
private disabledComponents;
|
|
539
|
+
/**
|
|
540
|
+
* Creates an entity without component
|
|
541
|
+
* @return the created Entity
|
|
542
|
+
* @public
|
|
543
|
+
* @category Core
|
|
544
|
+
* @example
|
|
545
|
+
* ```js
|
|
546
|
+
* const entity = entityManager.createEntity();
|
|
547
|
+
* ```
|
|
548
|
+
*/
|
|
549
|
+
createEntity(): Entity;
|
|
550
|
+
/**
|
|
551
|
+
* Creates an Entity based on a collection of Component instances and ComponentTypes
|
|
552
|
+
* @param components A collection of Component instances and ComponentTypes
|
|
553
|
+
* @public
|
|
554
|
+
* @category Core
|
|
555
|
+
* @example
|
|
556
|
+
* ```js
|
|
557
|
+
* const entity = entityManager.createEntity([
|
|
558
|
+
* new Transform({position: new Vector2(100, 100)}),
|
|
559
|
+
* SpriteRenderer
|
|
560
|
+
* ]);
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
createEntity(components: Array<ComponentType | Component>): Entity;
|
|
564
|
+
/**
|
|
565
|
+
* Removes an Entity and all its Components
|
|
566
|
+
* @param entity The entity to remove
|
|
567
|
+
* @public
|
|
568
|
+
* @category Core
|
|
569
|
+
* @example
|
|
570
|
+
* ```js
|
|
571
|
+
* entityManager.removeEntity(entity);
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
removeEntity(entity: Entity): void;
|
|
575
|
+
/**
|
|
576
|
+
* Removes all Entities and all their Components
|
|
577
|
+
* @public
|
|
578
|
+
* @category Core
|
|
579
|
+
* @example
|
|
580
|
+
* ```js
|
|
581
|
+
* entityManager.removeAllEntities();
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
removeAllEntities(): void;
|
|
585
|
+
/**
|
|
586
|
+
* Returns TRUE if the Entity is enabled, otherwise it returns FALSE
|
|
587
|
+
* @param entity The entity to verify
|
|
588
|
+
* @returns boolean
|
|
589
|
+
* @public
|
|
590
|
+
* @category Core
|
|
591
|
+
* @example
|
|
592
|
+
* ```js
|
|
593
|
+
* const entityEnabled = entityManager.isEntityEnabled(entity);
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
596
|
+
isEntityEnabled(entity: Entity): boolean;
|
|
597
|
+
/**
|
|
598
|
+
* Enables an Entity
|
|
599
|
+
* @param entity The entity to be enabled
|
|
600
|
+
* @public
|
|
601
|
+
* @category Core
|
|
602
|
+
* @example
|
|
603
|
+
* ```js
|
|
604
|
+
* entityManager.enableEntity(entity);
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
enableEntity(entity: Entity): void;
|
|
608
|
+
/**
|
|
609
|
+
* Disables an Entity
|
|
610
|
+
* @param entity The entity to be disabled
|
|
611
|
+
* @public
|
|
612
|
+
* @category Core
|
|
613
|
+
* @example
|
|
614
|
+
* ```js
|
|
615
|
+
* entityManager.disableEntity(entity);
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
disableEntity(entity: Entity): void;
|
|
619
|
+
/**
|
|
620
|
+
* Disable all Entities that have a component of the given type
|
|
621
|
+
* @param componentType The class of the component
|
|
622
|
+
* @public
|
|
623
|
+
* @category Core
|
|
624
|
+
* @example
|
|
625
|
+
* ```js
|
|
626
|
+
* entityManager.disableEntitiesByComponent(SpriteRenderer);
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
disableEntitiesByComponent(componentType: ComponentType): void;
|
|
630
|
+
/**
|
|
631
|
+
* Enable all Entities that have a component of the given type
|
|
632
|
+
* @param componentType The class of the component
|
|
633
|
+
* @public
|
|
634
|
+
* @category Core
|
|
635
|
+
* @example
|
|
636
|
+
* ```js
|
|
637
|
+
* entityManager.enableEntitiesByComponent(SpriteRenderer);
|
|
638
|
+
* ```
|
|
639
|
+
*/
|
|
640
|
+
enableEntitiesByComponent(componentType: ComponentType): void;
|
|
641
|
+
/**
|
|
642
|
+
* Adds a component to the entity
|
|
643
|
+
* @param entity The Entity to which the component will be added
|
|
644
|
+
* @param componentType The class of the component
|
|
645
|
+
* @returns The instance of the component
|
|
646
|
+
* @public
|
|
647
|
+
* @category Core
|
|
648
|
+
* @example
|
|
649
|
+
* ```js
|
|
650
|
+
* const spriteRenderer = entityManager.addComponent(entity, SpriteRenderer);
|
|
651
|
+
* ```
|
|
652
|
+
*/
|
|
653
|
+
addComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): T;
|
|
654
|
+
/**
|
|
655
|
+
* Adds an instance of a component to an entity
|
|
656
|
+
* @param entity The Entity to which the component will be added
|
|
657
|
+
* @param component The instance of the component
|
|
658
|
+
* @returns The instance of the component
|
|
659
|
+
* @public
|
|
660
|
+
* @category Core
|
|
661
|
+
* @example
|
|
662
|
+
* ```js
|
|
663
|
+
* const spriteRenderer = new SpriteRenderer();
|
|
664
|
+
* entityManager.addComponent(entity, spriteRenderer);
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
667
|
+
addComponent<T extends Component>(entity: Entity, component: T): T;
|
|
668
|
+
/**
|
|
669
|
+
* Returns TRUE if the Entity has a component of the given type, otherwise it returns FALSE.
|
|
670
|
+
* @param entity The entity to verify
|
|
671
|
+
* @param componentType The class of the component
|
|
672
|
+
* @returns boolean
|
|
673
|
+
* @public
|
|
674
|
+
* @category Core
|
|
675
|
+
* @example
|
|
676
|
+
* ```js
|
|
677
|
+
* const hasSpriteRenderer = entityManager.hasComponent(entity, SpriteRenderer);
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
hasComponent(entity: Entity, componentType: ComponentType): boolean;
|
|
681
|
+
/**
|
|
682
|
+
* Returns the component of the given type belonging to the entity
|
|
683
|
+
* @param entity The entity
|
|
684
|
+
* @param componentType The class of the component
|
|
685
|
+
* @returns The instance of the component
|
|
686
|
+
* @public
|
|
687
|
+
* @category Core
|
|
688
|
+
* @example
|
|
689
|
+
* ```js
|
|
690
|
+
* const spriteRenderer = entityManager.getComponent(entity, SpriteRenderer);
|
|
691
|
+
* ```
|
|
692
|
+
*/
|
|
693
|
+
getComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): T;
|
|
694
|
+
/**
|
|
695
|
+
* Returns all the component belonging to the entity
|
|
696
|
+
* @param entity The entity
|
|
697
|
+
* @returns A collection of component instances
|
|
698
|
+
* @public
|
|
699
|
+
* @category Core
|
|
700
|
+
* @example
|
|
701
|
+
* ```js
|
|
702
|
+
* const components = entityManager.getComponents(entity);
|
|
703
|
+
* ```
|
|
704
|
+
*/
|
|
705
|
+
getComponents(entity: Entity): Component[];
|
|
706
|
+
/**
|
|
707
|
+
* Searches for and returns an entity for the component instance
|
|
708
|
+
* @param component The component instance
|
|
709
|
+
* @returns The found Entity
|
|
710
|
+
* @public
|
|
711
|
+
* @category Core
|
|
712
|
+
* @example
|
|
713
|
+
* ```js
|
|
714
|
+
* const entity = entityManager.getEntityForComponent(spriteRenderer);
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
getEntityForComponent(component: Component): Entity;
|
|
718
|
+
/**
|
|
719
|
+
* Removes the component instance from its Entity
|
|
720
|
+
* @param component The component instance
|
|
721
|
+
* @public
|
|
722
|
+
* @category Core
|
|
723
|
+
* @example
|
|
724
|
+
* ```js
|
|
725
|
+
* entityManager.removeComponent(spriteRenderer)
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
removeComponent(component: Component): void;
|
|
729
|
+
/**
|
|
730
|
+
* Removes a component from the entity according to the given type
|
|
731
|
+
* @param entity The target entity
|
|
732
|
+
* @param componentType The component class
|
|
733
|
+
* @public
|
|
734
|
+
* @category Core
|
|
735
|
+
* @example
|
|
736
|
+
* ```js
|
|
737
|
+
* entityManager.removeComponent(entity, SriteRenderer)
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
removeComponent(entity: Entity, componentType: ComponentType): void;
|
|
741
|
+
/**
|
|
742
|
+
* Returns TRUE if the component is enabled, otherwise it returns FALSE
|
|
743
|
+
* @param component The component instance
|
|
744
|
+
* @returns boolean
|
|
745
|
+
* @public
|
|
746
|
+
* @category Core
|
|
747
|
+
* @example
|
|
748
|
+
* ```js
|
|
749
|
+
* entityManager.isComponentEnabled(spriteRenderer)
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
752
|
+
isComponentEnabled(component: Component): boolean;
|
|
753
|
+
/**
|
|
754
|
+
* Returns TRUE if the component is enabled, otherwise it returns FALSE
|
|
755
|
+
* @param entity The target entity
|
|
756
|
+
* @param componentType The component class
|
|
757
|
+
* @returns boolean
|
|
758
|
+
* @public
|
|
759
|
+
* @category Core
|
|
760
|
+
* @example
|
|
761
|
+
* ```js
|
|
762
|
+
* entityManager.isComponentEnabled(entity, SpriteRenderer)
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
isComponentEnabled<T extends Component>(entity: Entity, componentType: ComponentType<T>): boolean;
|
|
766
|
+
/**
|
|
767
|
+
* Disables a component instance
|
|
768
|
+
* @param component The component instance
|
|
769
|
+
* @public
|
|
770
|
+
* @category Core
|
|
771
|
+
* @example
|
|
772
|
+
* ```js
|
|
773
|
+
* entityManager.disableComponent(spriteRenderer);
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
disableComponent(component: Component): void;
|
|
777
|
+
/**
|
|
778
|
+
* Disables a component by its entity and type
|
|
779
|
+
* @param entity The target entity
|
|
780
|
+
* @param componentType The component class
|
|
781
|
+
* @public
|
|
782
|
+
* @category Core
|
|
783
|
+
* @example
|
|
784
|
+
* ```js
|
|
785
|
+
* entityManager.disableComponent(entity, SpriteRenderer);
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
disableComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): void;
|
|
789
|
+
/**
|
|
790
|
+
* Enables a component instance
|
|
791
|
+
* @param component The component instance
|
|
792
|
+
* @public
|
|
793
|
+
* @category Core
|
|
794
|
+
* @example
|
|
795
|
+
* ```js
|
|
796
|
+
* entityManager.enableComponent(spriteRenderer);
|
|
797
|
+
* ```
|
|
798
|
+
*/
|
|
799
|
+
enableComponent(component: Component): void;
|
|
800
|
+
/**
|
|
801
|
+
* Enables a component by its entity and type
|
|
802
|
+
* @param entity The target entity
|
|
803
|
+
* @param componentType The component class
|
|
804
|
+
* @public
|
|
805
|
+
* @category Core
|
|
806
|
+
* @example
|
|
807
|
+
* ```js
|
|
808
|
+
* entityManager.enableComponent(entity, SpriteRenderer);
|
|
809
|
+
* ```
|
|
810
|
+
*/
|
|
811
|
+
enableComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): void;
|
|
812
|
+
/**
|
|
813
|
+
* Performs a search for entities given a component type.\
|
|
814
|
+
* This method returns a collection of objects of type SearchResult, which has the entity found, and the instance of the component.\
|
|
815
|
+
* This search can be filtered by passing as a second argument an instance of SearchCriteria, which performs a match between the attributes of the component and the given value.\
|
|
816
|
+
* The third argument determines if disabled entities or components are included in the search result,\its default value is FALSE.
|
|
817
|
+
* @param componentType The component class
|
|
818
|
+
* @param criteria The search criteria
|
|
819
|
+
* @param includeDisabled TRUE to incluide disabled entities and components, FALSE otherwise
|
|
820
|
+
* @returns SearchResult
|
|
821
|
+
* @public
|
|
822
|
+
* @category Core
|
|
823
|
+
* @example
|
|
824
|
+
* ```js
|
|
825
|
+
* const searchResult = entityManager.search(SpriteRenderer);
|
|
826
|
+
* searchResult.forEach(({component, entity}) => {
|
|
827
|
+
* // do something with the component and entity
|
|
828
|
+
* })
|
|
829
|
+
* ```
|
|
830
|
+
* @example
|
|
831
|
+
* ```js
|
|
832
|
+
* const searchResult = entityManager.search(Enemy, {status: "alive"});
|
|
833
|
+
* searchResult.forEach(({component, entity}) => {
|
|
834
|
+
* // do something with the component and entity
|
|
835
|
+
* })
|
|
836
|
+
* ```
|
|
837
|
+
*/
|
|
838
|
+
search<T extends Component>(componentType: ComponentType<T>, criteria?: SearchCriteria, includeDisabled?: boolean): SearchResult<T>[];
|
|
839
|
+
/**
|
|
840
|
+
* Performs an entity search given a collection of component types.\
|
|
841
|
+
* The entities found must have an instance of all the given component types.\
|
|
842
|
+
* This method returns a collection of Entities.
|
|
843
|
+
* @param componentTypes A collection of component classes
|
|
844
|
+
* @returns A collection of entities
|
|
845
|
+
* @public
|
|
846
|
+
* @category Core
|
|
847
|
+
* @example
|
|
848
|
+
* ```js
|
|
849
|
+
* const entities = entityManager.searchEntitiesByComponents([Transform, SpriteRenderer, Animator]);
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
852
|
+
searchEntitiesByComponents(componentTypes: ComponentType[]): Entity[];
|
|
853
|
+
private getComponentTypeId;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* This interface is used for the creation of system classes. You will have to inject the dependencies you need manully.
|
|
858
|
+
* @public
|
|
859
|
+
* @category Core
|
|
860
|
+
* @example
|
|
861
|
+
* ```typescript
|
|
862
|
+
* class PlayerSystem implements System {
|
|
863
|
+
* @inject(Symbols.EntityManager) private readonly entityManager: EntityManager;
|
|
864
|
+
*
|
|
865
|
+
* public onUpdate() {
|
|
866
|
+
* this.entityManager.search(Player).forEach(({component, entity}) => {
|
|
867
|
+
* // do somethng
|
|
868
|
+
* });
|
|
869
|
+
* }
|
|
870
|
+
* }
|
|
871
|
+
* ```
|
|
872
|
+
*/
|
|
873
|
+
interface System {
|
|
874
|
+
/**
|
|
875
|
+
* This method is called the first time the system is enabled
|
|
876
|
+
* @public
|
|
877
|
+
*/
|
|
878
|
+
onCreate?(): void;
|
|
879
|
+
/**
|
|
880
|
+
* This method is called when the system is destroyed
|
|
881
|
+
* @public
|
|
882
|
+
*/
|
|
883
|
+
onDestroy?(): void;
|
|
884
|
+
/**
|
|
885
|
+
* This method is called when the system is disabled
|
|
886
|
+
* @public
|
|
887
|
+
*/
|
|
888
|
+
onDisabled?(): void;
|
|
889
|
+
/**
|
|
890
|
+
* This method is called when the system is enabled
|
|
891
|
+
* @public
|
|
892
|
+
*/
|
|
893
|
+
onEnabled?(): void;
|
|
894
|
+
/**
|
|
895
|
+
* This method is called once every frame
|
|
896
|
+
* @public
|
|
897
|
+
*/
|
|
898
|
+
onUpdate(): void;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* This type represents a system class
|
|
902
|
+
* @public
|
|
903
|
+
* @category Core
|
|
904
|
+
*/
|
|
905
|
+
type SystemType<T extends System = System> = {
|
|
906
|
+
new (...args: any[]): T;
|
|
907
|
+
};
|
|
908
|
+
/** @internal */
|
|
909
|
+
type SystemGroup = string | number | symbol;
|
|
910
|
+
/**
|
|
911
|
+
* The SystemManager manages the systems.\
|
|
912
|
+
* It provides the necessary methods for reading and writing systems.
|
|
913
|
+
* @public
|
|
914
|
+
* @category Core
|
|
915
|
+
*/
|
|
916
|
+
declare class SystemManager {
|
|
917
|
+
private systems;
|
|
918
|
+
/**
|
|
919
|
+
* @param systemType The system class
|
|
920
|
+
* @returns the systen index
|
|
921
|
+
*/
|
|
922
|
+
private findSystemIndex;
|
|
923
|
+
/**
|
|
924
|
+
* Adds a new system instance linked to a group
|
|
925
|
+
* @param system The system instance
|
|
926
|
+
* @param group The system group
|
|
927
|
+
* @internal
|
|
928
|
+
*/
|
|
929
|
+
addSystem(system: System, group: SystemGroup): void;
|
|
930
|
+
/**
|
|
931
|
+
* Returns TRUE if it has a system of the given type, otherwise it returns FALSE
|
|
932
|
+
* @param systemType The system class
|
|
933
|
+
* @returns boolean
|
|
934
|
+
* @public
|
|
935
|
+
* @example
|
|
936
|
+
* ```js
|
|
937
|
+
* const hasPlayerSystem = systemManager.hasSystem(PlayerSystem);
|
|
938
|
+
* ```
|
|
939
|
+
*/
|
|
940
|
+
hasSystem(systemType: SystemType): boolean;
|
|
941
|
+
/**
|
|
942
|
+
* Returns a system instance for the given type
|
|
943
|
+
* @param systemType The system class
|
|
944
|
+
* @returns The system instance
|
|
945
|
+
* @internal
|
|
946
|
+
*/
|
|
947
|
+
getSystem<T extends System>(systemType: SystemType<T>): T;
|
|
948
|
+
/**
|
|
949
|
+
* Enables a system by its type.\
|
|
950
|
+
* The method `onEnabled` of the system will be called. If the system is enabled for the first time, the method `onCreate` will also be called.
|
|
951
|
+
* @param systemType The system class
|
|
952
|
+
* @public
|
|
953
|
+
* @example
|
|
954
|
+
* ```js
|
|
955
|
+
* systemManager.enableSystem(PlayerSystem);
|
|
956
|
+
* ```
|
|
957
|
+
*/
|
|
958
|
+
enableSystem(systemType: SystemType): void;
|
|
959
|
+
/**
|
|
960
|
+
* Disables a system by its type.\
|
|
961
|
+
* The method `onDisabled` of the system will be called.
|
|
962
|
+
* @param systemType The system class
|
|
963
|
+
* @public
|
|
964
|
+
* @example
|
|
965
|
+
* ```js
|
|
966
|
+
* systemManager.disableSystem(PlayerSystem);
|
|
967
|
+
* ```
|
|
968
|
+
*/
|
|
969
|
+
disableSystem(systemType: SystemType): void;
|
|
970
|
+
/**
|
|
971
|
+
* Set the execution priority of a system.
|
|
972
|
+
* @param systemType The system class
|
|
973
|
+
* @param position the priority number
|
|
974
|
+
* @internal
|
|
975
|
+
*/
|
|
976
|
+
setExecutionOrder(systemType: SystemType, position: number): void;
|
|
977
|
+
/**
|
|
978
|
+
* Removes a system by its type.
|
|
979
|
+
* The method `onDestroy` of the system will be called.
|
|
980
|
+
* @param systemType The system class
|
|
981
|
+
* @internal
|
|
982
|
+
*/
|
|
983
|
+
removeSystem(systemType: SystemType): void;
|
|
984
|
+
/**
|
|
985
|
+
* Call the method onUpdate for systems belonging to the given group
|
|
986
|
+
* @param group The system group
|
|
987
|
+
* @internal
|
|
988
|
+
*/
|
|
989
|
+
update(group: SystemGroup): void;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* Represent a collision. It contains the colliders involved, the entities, and the resolution data.
|
|
994
|
+
* @category Collisions
|
|
995
|
+
* @public
|
|
996
|
+
*/
|
|
997
|
+
interface Collision {
|
|
998
|
+
/**
|
|
999
|
+
* The local collider component
|
|
1000
|
+
* @public
|
|
1001
|
+
*/
|
|
1002
|
+
localCollider: Collider;
|
|
1003
|
+
/**
|
|
1004
|
+
* The local entity
|
|
1005
|
+
* @public
|
|
1006
|
+
*/
|
|
1007
|
+
localEntity: Entity;
|
|
1008
|
+
/**
|
|
1009
|
+
* The remote collider component
|
|
1010
|
+
* @public
|
|
1011
|
+
*/
|
|
1012
|
+
remoteCollider: Collider;
|
|
1013
|
+
/**
|
|
1014
|
+
* The remote collider
|
|
1015
|
+
* @public
|
|
1016
|
+
*/
|
|
1017
|
+
remoteEntity: Entity;
|
|
1018
|
+
/**
|
|
1019
|
+
* Contains the information about the collision
|
|
1020
|
+
* @public
|
|
1021
|
+
*/
|
|
1022
|
+
resolution: CollisionResolution;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* The CollisionRepository has the necessary methods to perform queries on the current collisions
|
|
1027
|
+
* @public
|
|
1028
|
+
* @category Collisions
|
|
1029
|
+
*/
|
|
1030
|
+
declare class CollisionRepository {
|
|
1031
|
+
private collisions;
|
|
1032
|
+
/**
|
|
1033
|
+
* Searches for and returns a collection of collisions for the given collider
|
|
1034
|
+
* @param collider The local collider
|
|
1035
|
+
* @returns A collection of collisions
|
|
1036
|
+
*/
|
|
1037
|
+
findCollisionsForCollider(collider: Collider): Collision[];
|
|
1038
|
+
/**
|
|
1039
|
+
* Searches for and returns a collection of collisions for the given collider and layer
|
|
1040
|
+
* @param collider The local collider
|
|
1041
|
+
* @param layer The collision layer
|
|
1042
|
+
* @returns A collection of collisions
|
|
1043
|
+
*/
|
|
1044
|
+
findCollisionsForColliderAndLayer(collider: Collider, layer: string): Collision[];
|
|
1045
|
+
/**
|
|
1046
|
+
* Returns all the collisions
|
|
1047
|
+
* @public
|
|
1048
|
+
* @returns A collection of collisions
|
|
1049
|
+
*/
|
|
1050
|
+
findAll(): Collision[];
|
|
1051
|
+
/** @internal */
|
|
1052
|
+
persist(collision: Collision): void;
|
|
1053
|
+
/** @internal */
|
|
1054
|
+
removeAll(): void;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Array containing which layers will collide with each other.
|
|
1059
|
+
* @category Config
|
|
1060
|
+
* @public
|
|
1061
|
+
*/
|
|
1062
|
+
type CollisionMatrix = [string, string][];
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Game configuration options
|
|
1066
|
+
* @public
|
|
1067
|
+
* @category Config
|
|
1068
|
+
* @example
|
|
1069
|
+
* ```js
|
|
1070
|
+
* const gameConfig = {
|
|
1071
|
+
* containerNode: document.getElementById("app"),
|
|
1072
|
+
* width: 1920,
|
|
1073
|
+
* height: 1080,
|
|
1074
|
+
* debugEnabled: false,
|
|
1075
|
+
* canvasColor: "#000000",
|
|
1076
|
+
* physicsFramerate: 180,
|
|
1077
|
+
* headless: false,
|
|
1078
|
+
* collisions: {
|
|
1079
|
+
* collisionMatrix: [
|
|
1080
|
+
* ["layer1", "layer2"],
|
|
1081
|
+
* ["layer1", "layer3"],
|
|
1082
|
+
* ],
|
|
1083
|
+
* collisionMethod: CollisionMethods.SAT,
|
|
1084
|
+
* collisionBroadPhaseMethod: BroadPhaseMethods.SpartialGrid,
|
|
1085
|
+
* }
|
|
1086
|
+
* };
|
|
1087
|
+
* ```
|
|
1088
|
+
*/
|
|
1089
|
+
interface GameConfig {
|
|
1090
|
+
/** HTML element where the game will be created */
|
|
1091
|
+
containerNode: HTMLElement;
|
|
1092
|
+
/** Game width */
|
|
1093
|
+
width: number;
|
|
1094
|
+
/** Game height */
|
|
1095
|
+
height: number;
|
|
1096
|
+
/** Enables the debug mode */
|
|
1097
|
+
debugEnabled?: boolean;
|
|
1098
|
+
/** Background color of canvas */
|
|
1099
|
+
canvasColor?: string;
|
|
1100
|
+
/** Framerate for physics execution. The allowed values are 60, 120, 180, 240.
|
|
1101
|
+
* The higher the framerate, the more accurate the physics will be, but it will consume more processor resources.
|
|
1102
|
+
* Default value is 180.
|
|
1103
|
+
*/
|
|
1104
|
+
physicsFramerate?: number;
|
|
1105
|
+
/** Enable Headless mode. The input and rendering functions are turned off. Ideal for game server development */
|
|
1106
|
+
headless?: boolean;
|
|
1107
|
+
/** Collision configuration options */
|
|
1108
|
+
collisions?: {
|
|
1109
|
+
/** Collision detection method: CollisionMethods.SAT or CollisionMethods.ABB. Default value is CollisionMethods.SAT */
|
|
1110
|
+
collisionMethod?: CollisionMethods;
|
|
1111
|
+
/** Define a fixed rectangular area for collision detection */
|
|
1112
|
+
collisionMatrix?: CollisionMatrix;
|
|
1113
|
+
/** Collision broad phase method: BroadPhaseMethods.QuadTree or BroadPhaseMethods.SpartialGrid. Default values is BroadPhaseMethods.SpartialGrid */
|
|
1114
|
+
collisionBroadPhaseMethod?: BroadPhaseMethods;
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
declare class SystemFactory {
|
|
1119
|
+
private readonly container;
|
|
1120
|
+
private readonly systemManager;
|
|
1121
|
+
private lastSystemTypeId;
|
|
1122
|
+
constructor(container: Container, systemManager: SystemManager);
|
|
1123
|
+
createSystemIfNotExists(systemType: SystemType): void;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Manages the asset loading (images, fonts, audios, videos).
|
|
1128
|
+
* @public
|
|
1129
|
+
* @category Managers
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```js
|
|
1132
|
+
* this.assetManager.loadImage("image.png");
|
|
1133
|
+
* this.assetManager.loadAudio("audio.ogg");
|
|
1134
|
+
* this.assetManager.loadVideo("video.mp4");
|
|
1135
|
+
* this.assetManager.loadFont("custom-font", "custom-font.ttf");
|
|
1136
|
+
*
|
|
1137
|
+
* const imageElement = this.assetManager.getImage("image.png");
|
|
1138
|
+
* const audioElement = this.assetManager.getAudio("audio.ogg");
|
|
1139
|
+
* const videoElement = this.assetManager.getVideo("video.mp4");
|
|
1140
|
+
* const fontFace = this.assetManager.getFont("custom-font");
|
|
1141
|
+
*
|
|
1142
|
+
* if (this.assetManager.getAssetsLoaded()) {
|
|
1143
|
+
* // do something when assets are loaded
|
|
1144
|
+
* }
|
|
1145
|
+
* ```
|
|
1146
|
+
*/
|
|
1147
|
+
declare class AssetManager {
|
|
1148
|
+
private readonly assets;
|
|
1149
|
+
/**
|
|
1150
|
+
* Returns TRUE if the assets are loaded
|
|
1151
|
+
* @returns TRUE or FALSE
|
|
1152
|
+
*/
|
|
1153
|
+
getAssetsLoaded(): boolean;
|
|
1154
|
+
/**
|
|
1155
|
+
* Loads an image asset
|
|
1156
|
+
* @param url The asset URL
|
|
1157
|
+
* @returns The HTML Image element created
|
|
1158
|
+
*/
|
|
1159
|
+
loadImage(url: string): HTMLImageElement;
|
|
1160
|
+
/**
|
|
1161
|
+
* Loads an audio asset
|
|
1162
|
+
* @param url The asset URL
|
|
1163
|
+
* @returns The HTML Audio element created
|
|
1164
|
+
*/
|
|
1165
|
+
loadAudio(url: string): HTMLAudioElement;
|
|
1166
|
+
/**
|
|
1167
|
+
* Loads a font asset
|
|
1168
|
+
* @param family The font family name
|
|
1169
|
+
* @param url The asset URL
|
|
1170
|
+
* @returns The FontFace object created
|
|
1171
|
+
*/
|
|
1172
|
+
loadFont(family: string, url: string): FontFace;
|
|
1173
|
+
/**
|
|
1174
|
+
* Loads an video asset
|
|
1175
|
+
* @param url The asset URL
|
|
1176
|
+
* @returns The HTML Video element created
|
|
1177
|
+
*/
|
|
1178
|
+
loadVideo(url: string): HTMLVideoElement;
|
|
1179
|
+
/**
|
|
1180
|
+
* Retrieves an image asset
|
|
1181
|
+
* @param url The asset URL
|
|
1182
|
+
* @returns The HTML Image element
|
|
1183
|
+
*/
|
|
1184
|
+
getImage(url: string): HTMLImageElement;
|
|
1185
|
+
/**
|
|
1186
|
+
* Retrieves an audio asset
|
|
1187
|
+
* @param url The asset URL
|
|
1188
|
+
* @returns The HTML Audio element
|
|
1189
|
+
*/
|
|
1190
|
+
getAudio(url: string): HTMLAudioElement;
|
|
1191
|
+
/**
|
|
1192
|
+
* Retrieves a font asset
|
|
1193
|
+
* @param family The font family name
|
|
1194
|
+
* @returns The Font element
|
|
1195
|
+
*/
|
|
1196
|
+
getFont(family: string): FontFace;
|
|
1197
|
+
/**
|
|
1198
|
+
* Retrieves a video asset
|
|
1199
|
+
* @param url The asset URL
|
|
1200
|
+
* @returns The HTML Video element
|
|
1201
|
+
*/
|
|
1202
|
+
getVideo(url: string): HTMLVideoElement;
|
|
1203
|
+
private createAsset;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* This type represents a scene class
|
|
1208
|
+
* @public
|
|
1209
|
+
* @category Core
|
|
1210
|
+
*/
|
|
1211
|
+
type SceneType<T extends Scene = Scene> = {
|
|
1212
|
+
new (entityManager: EntityManager, assetManager: AssetManager): T;
|
|
1213
|
+
};
|
|
1214
|
+
/**
|
|
1215
|
+
* Base class for all game scenes
|
|
1216
|
+
* @public
|
|
1217
|
+
* @category Core
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```js
|
|
1220
|
+
* class GameScene extends Scene {
|
|
1221
|
+
* systems = [
|
|
1222
|
+
* SomeSystem,
|
|
1223
|
+
* AnotherSystem
|
|
1224
|
+
* ];
|
|
1225
|
+
*
|
|
1226
|
+
* loadAssets() {
|
|
1227
|
+
* this.assetManager.loadImage("image.png");
|
|
1228
|
+
* }
|
|
1229
|
+
*
|
|
1230
|
+
* setup() {
|
|
1231
|
+
* this.entityManager.createEntity([
|
|
1232
|
+
* SomeComponent,
|
|
1233
|
+
* AnotherComponent
|
|
1234
|
+
* ]);
|
|
1235
|
+
* }
|
|
1236
|
+
* }
|
|
1237
|
+
* ```
|
|
1238
|
+
*/
|
|
1239
|
+
declare abstract class Scene {
|
|
1240
|
+
protected readonly entityManager: EntityManager;
|
|
1241
|
+
protected readonly assetManager: AssetManager;
|
|
1242
|
+
systems: SystemType[];
|
|
1243
|
+
constructor(entityManager: EntityManager, assetManager: AssetManager);
|
|
1244
|
+
loadAssets(): void;
|
|
1245
|
+
setup(): void;
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Manges the loading of the scenes.
|
|
1249
|
+
* @public
|
|
1250
|
+
* @category Managers
|
|
1251
|
+
* @example
|
|
1252
|
+
* ```js
|
|
1253
|
+
* this.sceneManager.loadScene("MainScene");
|
|
1254
|
+
* ```
|
|
1255
|
+
*/
|
|
1256
|
+
declare class SceneManager {
|
|
1257
|
+
private readonly systemManager;
|
|
1258
|
+
private readonly systemFactory;
|
|
1259
|
+
private readonly entityManager;
|
|
1260
|
+
private readonly assetManager;
|
|
1261
|
+
private readonly scenes;
|
|
1262
|
+
private openingSceneName;
|
|
1263
|
+
private currentSceneName;
|
|
1264
|
+
private sceneNameToBeLoaded;
|
|
1265
|
+
private loadingScene;
|
|
1266
|
+
/** @internal */
|
|
1267
|
+
constructor(systemManager: SystemManager, systemFactory: SystemFactory, entityManager: EntityManager, assetManager: AssetManager);
|
|
1268
|
+
addScene(sceneType: SceneType, name: string, openingScene?: boolean): void;
|
|
1269
|
+
loadScene(name: string): void;
|
|
1270
|
+
loadOpeningScene(): void;
|
|
1271
|
+
/** @internal */
|
|
1272
|
+
update(): void;
|
|
1273
|
+
private destroyCurrentScene;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Game is the main class that contains all the managers, scenes, entities and components. It allows to start and stop the execution of the game.
|
|
1278
|
+
* @public
|
|
1279
|
+
* @category Core
|
|
1280
|
+
* @example
|
|
1281
|
+
* ```js
|
|
1282
|
+
* const game = new Game({
|
|
1283
|
+
* containerNode: document.getElementById("app"),
|
|
1284
|
+
* width: 1920,
|
|
1285
|
+
* height: 1080,
|
|
1286
|
+
* });
|
|
1287
|
+
* game.addScene(MainScene, "MainScene");
|
|
1288
|
+
* game.start();
|
|
1289
|
+
* ```
|
|
1290
|
+
* @example
|
|
1291
|
+
* ```js
|
|
1292
|
+
* const game = new Game({
|
|
1293
|
+
* containerNode: document.getElementById("app"),
|
|
1294
|
+
* width: 1920,
|
|
1295
|
+
* height: 1080,
|
|
1296
|
+
* debugEnabled: false,
|
|
1297
|
+
* canvasColor: "#000000",
|
|
1298
|
+
* physicsFramerate: 180,
|
|
1299
|
+
* collisions: {
|
|
1300
|
+
* collisionMatrix: [
|
|
1301
|
+
* ["layer1", "layer2"],
|
|
1302
|
+
* ["layer1", "layer3"],
|
|
1303
|
+
* ],
|
|
1304
|
+
* collisionMethod: CollisionMethods.SAT,
|
|
1305
|
+
* collisionBroadPhaseMethod: BroadPhaseMethods.SpartialGrid,
|
|
1306
|
+
* }
|
|
1307
|
+
* });
|
|
1308
|
+
* game.addScene(MainScene, "MainScene");
|
|
1309
|
+
* game.start();
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
declare class Game {
|
|
1313
|
+
private readonly container;
|
|
1314
|
+
constructor(gameConfig: GameConfig);
|
|
1315
|
+
/**
|
|
1316
|
+
* TRUE if the game is running
|
|
1317
|
+
*/
|
|
1318
|
+
get running(): boolean;
|
|
1319
|
+
/**
|
|
1320
|
+
* Add a scene to the game
|
|
1321
|
+
*
|
|
1322
|
+
* @param sceneType The class of the scene
|
|
1323
|
+
* @param name The name for the scene
|
|
1324
|
+
* @param openingScene If this is the opening scene, set TRUE, FALSE instead (optional: default FALSE)
|
|
1325
|
+
*/
|
|
1326
|
+
addScene(sceneType: SceneType, name: string, openingScene?: boolean): void;
|
|
1327
|
+
/**
|
|
1328
|
+
* Add a new class to be used as dependency
|
|
1329
|
+
*
|
|
1330
|
+
* @param dependencyType The class of the dependency
|
|
1331
|
+
* @param name The name for the dependecy (optional: if the class uses the "injectable" decorator, this parameter is unnecesary)
|
|
1332
|
+
*/
|
|
1333
|
+
addDependencyType(dependencyType: DependencyType, name?: DependencyName): void;
|
|
1334
|
+
/**
|
|
1335
|
+
* Add a new instance to be used as dependency
|
|
1336
|
+
*
|
|
1337
|
+
* @param dependencyInstance The dependency instance
|
|
1338
|
+
* @param name The name for the dependecy
|
|
1339
|
+
*/
|
|
1340
|
+
addDependencyInstance(dependencyInstance: any, name: DependencyName): void;
|
|
1341
|
+
/**
|
|
1342
|
+
* Start the game
|
|
1343
|
+
*/
|
|
1344
|
+
start(): void;
|
|
1345
|
+
/**
|
|
1346
|
+
* Stop the game
|
|
1347
|
+
*/
|
|
1348
|
+
stop(): void;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* @public
|
|
1353
|
+
* @category Components
|
|
1354
|
+
*/
|
|
1355
|
+
interface AnimatorOptions {
|
|
1356
|
+
animations: Map<string, Animation>;
|
|
1357
|
+
animation: string;
|
|
1358
|
+
speed: number;
|
|
1359
|
+
playing: boolean;
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* @public
|
|
1363
|
+
* @category Components
|
|
1364
|
+
*/
|
|
1365
|
+
declare class Animator {
|
|
1366
|
+
animations: Map<string, Animation>;
|
|
1367
|
+
animation: string;
|
|
1368
|
+
speed: number;
|
|
1369
|
+
reset: boolean;
|
|
1370
|
+
playing: boolean;
|
|
1371
|
+
currentFrame: number;
|
|
1372
|
+
currentTime: number;
|
|
1373
|
+
/** @internal */
|
|
1374
|
+
_currentAnimation: string;
|
|
1375
|
+
constructor(options?: Partial<AnimatorOptions>);
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* @public
|
|
1379
|
+
* @category Components
|
|
1380
|
+
*/
|
|
1381
|
+
declare class Animation {
|
|
1382
|
+
image: HTMLImageElement | HTMLImageElement[];
|
|
1383
|
+
slice: AnimationSlice;
|
|
1384
|
+
frames: number[];
|
|
1385
|
+
fps: number;
|
|
1386
|
+
loop: boolean;
|
|
1387
|
+
constructor(options?: Partial<Animation>);
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* @public
|
|
1391
|
+
* @category Components
|
|
1392
|
+
*/
|
|
1393
|
+
type AnimationSlice = {
|
|
1394
|
+
size: Vector2;
|
|
1395
|
+
offset: Vector2;
|
|
1396
|
+
padding: Vector2;
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* @public
|
|
1401
|
+
* @category Components
|
|
1402
|
+
*/
|
|
1403
|
+
interface AudioPlayerOptions {
|
|
1404
|
+
action: AudioPlayerAction;
|
|
1405
|
+
audioSource: HTMLAudioElement;
|
|
1406
|
+
loop: boolean;
|
|
1407
|
+
volume: number;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* @public
|
|
1411
|
+
* @category Components
|
|
1412
|
+
*/
|
|
1413
|
+
declare class AudioPlayer {
|
|
1414
|
+
action: AudioPlayerAction;
|
|
1415
|
+
audioSource: HTMLAudioElement;
|
|
1416
|
+
loop: boolean;
|
|
1417
|
+
playing: boolean;
|
|
1418
|
+
volume: number;
|
|
1419
|
+
/** @internal */
|
|
1420
|
+
_currentAudio: string;
|
|
1421
|
+
constructor(options?: Partial<AudioPlayerOptions>);
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* @public
|
|
1425
|
+
* @category Components
|
|
1426
|
+
*/
|
|
1427
|
+
type AudioPlayerAction = "stop" | "play" | "pause";
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* @public
|
|
1431
|
+
* @category Components
|
|
1432
|
+
*/
|
|
1433
|
+
interface ButtonOptions {
|
|
1434
|
+
shape: ButtonShape;
|
|
1435
|
+
width: number;
|
|
1436
|
+
height: number;
|
|
1437
|
+
radius: number;
|
|
1438
|
+
touchEnabled: boolean;
|
|
1439
|
+
offset: Vector2;
|
|
1440
|
+
onClick: () => void;
|
|
1441
|
+
onPressed: () => void;
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* @public
|
|
1445
|
+
* @category Components
|
|
1446
|
+
*/
|
|
1447
|
+
declare class Button {
|
|
1448
|
+
/** The shape of the button */
|
|
1449
|
+
shape: ButtonShape;
|
|
1450
|
+
/** Width in pixels. Only for rectangle shaped buttons */
|
|
1451
|
+
width: number;
|
|
1452
|
+
/** Height in pixels. Only for rectangle shaped buttons */
|
|
1453
|
+
height: number;
|
|
1454
|
+
/** Radius in pixels. Only for circumference shaped buttons */
|
|
1455
|
+
radius: number;
|
|
1456
|
+
/** Enables interaction with touch screens */
|
|
1457
|
+
touchEnabled: boolean;
|
|
1458
|
+
/** X-axis and Y-axis offset */
|
|
1459
|
+
offset: Vector2;
|
|
1460
|
+
/** TRUE if it's pressed */
|
|
1461
|
+
pressed: boolean;
|
|
1462
|
+
/** Function executed when the button's click */
|
|
1463
|
+
onClick: () => void;
|
|
1464
|
+
/** Function executed when the button is pressed */
|
|
1465
|
+
onPressed: () => void;
|
|
1466
|
+
constructor(options?: Partial<ButtonOptions>);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* @public
|
|
1470
|
+
* @category Components
|
|
1471
|
+
*/
|
|
1472
|
+
declare enum ButtonShape {
|
|
1473
|
+
Rectangle = 0,
|
|
1474
|
+
Circumference = 1
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* @public
|
|
1479
|
+
* @category Components
|
|
1480
|
+
*/
|
|
1481
|
+
declare class Children {
|
|
1482
|
+
entities: Entity[];
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* @public
|
|
1487
|
+
* @category Components
|
|
1488
|
+
*/
|
|
1489
|
+
declare class Parent {
|
|
1490
|
+
entity: Entity;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* @public
|
|
1495
|
+
* @category Components
|
|
1496
|
+
*/
|
|
1497
|
+
interface TiledWrapperOptions {
|
|
1498
|
+
tilemap: TiledTilemap;
|
|
1499
|
+
layerToRender: string;
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* @public
|
|
1503
|
+
* @category Components
|
|
1504
|
+
*/
|
|
1505
|
+
declare class TiledWrapper {
|
|
1506
|
+
tilemap: TiledTilemap;
|
|
1507
|
+
layerToRender: string;
|
|
1508
|
+
constructor(options?: Partial<TiledWrapperOptions>);
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* @public
|
|
1512
|
+
* @category Components
|
|
1513
|
+
*/
|
|
1514
|
+
interface TiledTilemap {
|
|
1515
|
+
width: number;
|
|
1516
|
+
height: number;
|
|
1517
|
+
infinite: boolean;
|
|
1518
|
+
layers: (TiledLayer | TiledObjectLayer)[];
|
|
1519
|
+
renderorder: string;
|
|
1520
|
+
tilesets: {
|
|
1521
|
+
firstgid: number;
|
|
1522
|
+
}[];
|
|
1523
|
+
tilewidth: number;
|
|
1524
|
+
tileheight: number;
|
|
1525
|
+
properties?: TiledProperty[];
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* @public
|
|
1529
|
+
* @category Components
|
|
1530
|
+
*/
|
|
1531
|
+
interface TiledChunk {
|
|
1532
|
+
data: number[];
|
|
1533
|
+
x: number;
|
|
1534
|
+
y: number;
|
|
1535
|
+
width: number;
|
|
1536
|
+
height: number;
|
|
1537
|
+
type?: string;
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* @public
|
|
1541
|
+
* @category Components
|
|
1542
|
+
*/
|
|
1543
|
+
interface TiledLayer {
|
|
1544
|
+
name: string;
|
|
1545
|
+
id: number;
|
|
1546
|
+
chunks?: TiledChunk[];
|
|
1547
|
+
data?: number[];
|
|
1548
|
+
x: number;
|
|
1549
|
+
y: number;
|
|
1550
|
+
type: "tilelayer";
|
|
1551
|
+
width: number;
|
|
1552
|
+
height: number;
|
|
1553
|
+
opacity: number;
|
|
1554
|
+
visible: boolean;
|
|
1555
|
+
startx?: number;
|
|
1556
|
+
starty?: number;
|
|
1557
|
+
offsetx?: number;
|
|
1558
|
+
offsety?: number;
|
|
1559
|
+
tintcolor?: string;
|
|
1560
|
+
properties?: TiledProperty[];
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* @public
|
|
1564
|
+
* @category Components
|
|
1565
|
+
*/
|
|
1566
|
+
interface TiledObjectLayer {
|
|
1567
|
+
draworder: string;
|
|
1568
|
+
id: number;
|
|
1569
|
+
name: string;
|
|
1570
|
+
objects: TiledObject[];
|
|
1571
|
+
opacity: number;
|
|
1572
|
+
type: "objectgroup";
|
|
1573
|
+
visible: true;
|
|
1574
|
+
x: number;
|
|
1575
|
+
y: number;
|
|
1576
|
+
properties?: TiledProperty[];
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* @public
|
|
1580
|
+
* @category Components
|
|
1581
|
+
*/
|
|
1582
|
+
interface TiledObject {
|
|
1583
|
+
gid: number;
|
|
1584
|
+
height: number;
|
|
1585
|
+
id: number;
|
|
1586
|
+
name: string;
|
|
1587
|
+
rotation: number;
|
|
1588
|
+
type: string;
|
|
1589
|
+
visible: true;
|
|
1590
|
+
width: number;
|
|
1591
|
+
x: number;
|
|
1592
|
+
y: number;
|
|
1593
|
+
properties?: TiledProperty[];
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* @public
|
|
1597
|
+
* @category Components
|
|
1598
|
+
*/
|
|
1599
|
+
interface TiledProperty {
|
|
1600
|
+
name: string;
|
|
1601
|
+
type: "int" | "bool" | "float" | "color" | "string";
|
|
1602
|
+
value: number | string | boolean;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* @public
|
|
1607
|
+
* @category Components
|
|
1608
|
+
*/
|
|
1609
|
+
interface TransformOptions {
|
|
1610
|
+
position: Vector2;
|
|
1611
|
+
scale: Vector2;
|
|
1612
|
+
rotation: number;
|
|
1613
|
+
parent: Transform;
|
|
1614
|
+
localPosition: Vector2;
|
|
1615
|
+
localScale: Vector2;
|
|
1616
|
+
localRotation: number;
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* @public
|
|
1620
|
+
* @category Components
|
|
1621
|
+
*/
|
|
1622
|
+
declare class Transform {
|
|
1623
|
+
/** Position relative to the zero point of the simulated world, or relative to the parent if it has one */
|
|
1624
|
+
position: Vector2;
|
|
1625
|
+
/** Scale on x-axis and y-axis */
|
|
1626
|
+
scale: Vector2;
|
|
1627
|
+
/** Rotation expressed in radians */
|
|
1628
|
+
rotation: number;
|
|
1629
|
+
/** The real position in the simulated world. It has the same value as `position` property if there is no parent */
|
|
1630
|
+
localPosition: Vector2;
|
|
1631
|
+
/** The real scale in the simulated world. It has the same value as `scale` property if there is no parent */
|
|
1632
|
+
localScale: Vector2;
|
|
1633
|
+
/** The real rotation in the simulated world. It has the same value as `rotation` property if there is no parent */
|
|
1634
|
+
localRotation: number;
|
|
1635
|
+
/** @internal */
|
|
1636
|
+
_parentEntity: Entity;
|
|
1637
|
+
/** @internal */
|
|
1638
|
+
_childEntities: Entity[];
|
|
1639
|
+
private _parent;
|
|
1640
|
+
/** The parent transform. The position property became relative to this transform */
|
|
1641
|
+
get parent(): Transform;
|
|
1642
|
+
/** The parent transform. The position property became relative to this transform */
|
|
1643
|
+
set parent(parent: Transform);
|
|
1644
|
+
constructor(options?: Partial<TransformOptions>);
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* Configuration object for BallCollider creation
|
|
1649
|
+
* @public
|
|
1650
|
+
* @category Components
|
|
1651
|
+
* @example
|
|
1652
|
+
* ```js
|
|
1653
|
+
* const ballCollider = new BallCollider({
|
|
1654
|
+
* radius: 16,
|
|
1655
|
+
* offset: new Vector2(),
|
|
1656
|
+
* layer: "CollisionLayer",
|
|
1657
|
+
* physics: true,
|
|
1658
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1659
|
+
* });
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
interface BallColliderOptions {
|
|
1663
|
+
/** Circumference radius */
|
|
1664
|
+
radius: number;
|
|
1665
|
+
/** X-Y axis offset */
|
|
1666
|
+
offset: Vector2;
|
|
1667
|
+
/** Collision layer*/
|
|
1668
|
+
layer: string;
|
|
1669
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1670
|
+
physics: boolean;
|
|
1671
|
+
/** Ignores collisions with layers in the array */
|
|
1672
|
+
ignoreCollisionsWithLayers: string[];
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Circumference shaped collider for 2d collisions.
|
|
1676
|
+
* @public
|
|
1677
|
+
* @category Components
|
|
1678
|
+
* @example
|
|
1679
|
+
* ```js
|
|
1680
|
+
* const ballCollider = new BallCollider({
|
|
1681
|
+
* radius: 16,
|
|
1682
|
+
* offset: new Vector2(),
|
|
1683
|
+
* layer: "CollisionLayer",
|
|
1684
|
+
* physics: true,
|
|
1685
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1686
|
+
* });
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
declare class BallCollider implements Collider {
|
|
1690
|
+
/** Circumference radius */
|
|
1691
|
+
radius: number;
|
|
1692
|
+
/** X-Y axis offset */
|
|
1693
|
+
offset: Vector2;
|
|
1694
|
+
/** Collision layer*/
|
|
1695
|
+
layer: string;
|
|
1696
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1697
|
+
physics: boolean;
|
|
1698
|
+
/** Ignores collisions with layers in the array */
|
|
1699
|
+
ignoreCollisionsWithLayers: string[];
|
|
1700
|
+
/** @internal */
|
|
1701
|
+
shapes: Shape[];
|
|
1702
|
+
constructor(options?: Partial<BallColliderOptions>);
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* Configuration object for BoxCollider creation
|
|
1707
|
+
* @public
|
|
1708
|
+
* @category Components
|
|
1709
|
+
* @example
|
|
1710
|
+
* ```js
|
|
1711
|
+
* const boxCollider = new BoxCollider({
|
|
1712
|
+
* width: 16,
|
|
1713
|
+
* height: 16,
|
|
1714
|
+
* rotation: 0,
|
|
1715
|
+
* offset: new Vector2(),
|
|
1716
|
+
* layer: "CollisionLayer",
|
|
1717
|
+
* physics: true,
|
|
1718
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1719
|
+
* });
|
|
1720
|
+
* ```
|
|
1721
|
+
*/
|
|
1722
|
+
interface BoxColliderOptions {
|
|
1723
|
+
/** Collision layer*/
|
|
1724
|
+
layer: string;
|
|
1725
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1726
|
+
physics: boolean;
|
|
1727
|
+
/** Width of the rectangle */
|
|
1728
|
+
width: number;
|
|
1729
|
+
/** Height of the rectangle */
|
|
1730
|
+
height: number;
|
|
1731
|
+
/** X-Y axis offset */
|
|
1732
|
+
offset: Vector2;
|
|
1733
|
+
/** Rectangle rotation in radians */
|
|
1734
|
+
rotation: number;
|
|
1735
|
+
/** Ignores collisions with layers in the array */
|
|
1736
|
+
ignoreCollisionsWithLayers: string[];
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Rectangle shaped collider for 2d collisions.
|
|
1740
|
+
* @public
|
|
1741
|
+
* @category Components
|
|
1742
|
+
* @example
|
|
1743
|
+
* ```js
|
|
1744
|
+
* const boxCollider = new BoxCollider({
|
|
1745
|
+
* width: 16,
|
|
1746
|
+
* height: 16,
|
|
1747
|
+
* rotation: 0,
|
|
1748
|
+
* offset: new Vector2(),
|
|
1749
|
+
* layer: "CollisionLayer",
|
|
1750
|
+
* physics: true,
|
|
1751
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1752
|
+
* });
|
|
1753
|
+
* ```
|
|
1754
|
+
*/
|
|
1755
|
+
declare class BoxCollider implements Collider {
|
|
1756
|
+
/** Collision layer*/
|
|
1757
|
+
layer: string;
|
|
1758
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1759
|
+
physics: boolean;
|
|
1760
|
+
/** Width of the rectangle */
|
|
1761
|
+
width: number;
|
|
1762
|
+
/** Height of the rectangle */
|
|
1763
|
+
height: number;
|
|
1764
|
+
/** X-Y axis offset */
|
|
1765
|
+
offset: Vector2;
|
|
1766
|
+
/** Rectangle rotation in radians */
|
|
1767
|
+
rotation: number;
|
|
1768
|
+
/** Ignores collisions with layers in the array */
|
|
1769
|
+
ignoreCollisionsWithLayers: string[];
|
|
1770
|
+
/** @internal */
|
|
1771
|
+
shapes: Shape[];
|
|
1772
|
+
constructor(options?: Partial<BoxColliderOptions>);
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
/**
|
|
1776
|
+
* Configuration object for EdgeCollider creation
|
|
1777
|
+
* @public
|
|
1778
|
+
* @category Components
|
|
1779
|
+
* @example
|
|
1780
|
+
* ```js
|
|
1781
|
+
* const edgeCollider = new EdgeCollider({
|
|
1782
|
+
* vertexModel: [new Vector2(0, 16), new Vector2(16, 16)],
|
|
1783
|
+
* rotation: 0,
|
|
1784
|
+
* offset: new Vector2(),
|
|
1785
|
+
* layer: "CollisionLayer",
|
|
1786
|
+
* physics: true,
|
|
1787
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1788
|
+
* });
|
|
1789
|
+
* ```
|
|
1790
|
+
*/
|
|
1791
|
+
interface EdgeColliderOptions {
|
|
1792
|
+
/** Collection of 2d vectors representing the vertices of the collider */
|
|
1793
|
+
vertexModel: Vector2[];
|
|
1794
|
+
/** X-Y axis offset */
|
|
1795
|
+
offset: Vector2;
|
|
1796
|
+
/** Edges rotation in radians */
|
|
1797
|
+
rotation: number;
|
|
1798
|
+
/** Collision layer */
|
|
1799
|
+
layer: string;
|
|
1800
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1801
|
+
physics: boolean;
|
|
1802
|
+
/** Ignores collisions with layers in the array */
|
|
1803
|
+
ignoreCollisionsWithLayers: string[];
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Collider composed of lines defined by its vertices, for 2d collisions.
|
|
1807
|
+
* @public
|
|
1808
|
+
* @category Components
|
|
1809
|
+
* @example
|
|
1810
|
+
* ```js
|
|
1811
|
+
* const edgeCollider = new EdgeCollider({
|
|
1812
|
+
* vertexModel: [new Vector2(0, 16), new Vector2(16, 16)],
|
|
1813
|
+
* offset: new Vector2(),
|
|
1814
|
+
* layer: "CollisionLayer",
|
|
1815
|
+
* physics: true,
|
|
1816
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1817
|
+
* });
|
|
1818
|
+
* ```
|
|
1819
|
+
*/
|
|
1820
|
+
declare class EdgeCollider implements Collider {
|
|
1821
|
+
/** Collection of 2d vectors representing the vertices of the collider */
|
|
1822
|
+
vertexModel: Vector2[];
|
|
1823
|
+
/** X-Y axis offset */
|
|
1824
|
+
offset: Vector2;
|
|
1825
|
+
/** Edges rotation in radians */
|
|
1826
|
+
rotation: number;
|
|
1827
|
+
/** Collision layer */
|
|
1828
|
+
layer: string;
|
|
1829
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1830
|
+
physics: boolean;
|
|
1831
|
+
/** Ignores collisions with layers in the array */
|
|
1832
|
+
ignoreCollisionsWithLayers: string[];
|
|
1833
|
+
/** @internal */
|
|
1834
|
+
shapes: Shape[];
|
|
1835
|
+
constructor(options?: Partial<EdgeColliderOptions>);
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
/**
|
|
1839
|
+
* Configuration object for PolygonCollider creation
|
|
1840
|
+
* @public
|
|
1841
|
+
* @category Components
|
|
1842
|
+
* @example
|
|
1843
|
+
* ```js
|
|
1844
|
+
* const polygonCollider = new PolygonCollider({
|
|
1845
|
+
* vertexModel: [new Vector2(0, 16), new Vector2(16, 16), new Vector2(16, 0), new Vector2(0, 0)],
|
|
1846
|
+
* rotation: 0,
|
|
1847
|
+
* offset: new Vector2(),
|
|
1848
|
+
* layer: "CollisionLayer",
|
|
1849
|
+
* physics: true,
|
|
1850
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1851
|
+
* });
|
|
1852
|
+
* ```
|
|
1853
|
+
*/
|
|
1854
|
+
interface PolygonColliderOptions {
|
|
1855
|
+
/** Collection of 2d vectors representing the vertices of the collider */
|
|
1856
|
+
vertexModel: Vector2[];
|
|
1857
|
+
/** X-Y axis offset */
|
|
1858
|
+
offset: Vector2;
|
|
1859
|
+
/** Edges rotation in radians */
|
|
1860
|
+
rotation: number;
|
|
1861
|
+
/** Collision layer */
|
|
1862
|
+
layer: string;
|
|
1863
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1864
|
+
physics: boolean;
|
|
1865
|
+
/** Ignores collisions with layers in the array */
|
|
1866
|
+
ignoreCollisionsWithLayers: string[];
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Polygon shaped Collider for 2d collisions. Only convex polygons are allowed.
|
|
1870
|
+
* @public
|
|
1871
|
+
* @category Components
|
|
1872
|
+
* @example
|
|
1873
|
+
* ```js
|
|
1874
|
+
* const polygonCollider = new PolygonCollider({
|
|
1875
|
+
* vertexModel: [new Vector2(0, 16), new Vector2(16, 16), new Vector2(16, 0), new Vector2(0, 0)],
|
|
1876
|
+
* rotation: 0,
|
|
1877
|
+
* offset: new Vector2(),
|
|
1878
|
+
* layer: "CollisionLayer",
|
|
1879
|
+
* physics: true,
|
|
1880
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
1881
|
+
* });
|
|
1882
|
+
* ```
|
|
1883
|
+
*/
|
|
1884
|
+
declare class PolygonCollider implements Collider {
|
|
1885
|
+
/** Collection of 2d vectors representing the vertices of the collider */
|
|
1886
|
+
vertexModel: Vector2[];
|
|
1887
|
+
/** X-Y axis offset */
|
|
1888
|
+
offset: Vector2;
|
|
1889
|
+
/** Edges rotation in radians */
|
|
1890
|
+
rotation: number;
|
|
1891
|
+
/** Collision layer */
|
|
1892
|
+
layer: string;
|
|
1893
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
1894
|
+
physics: boolean;
|
|
1895
|
+
/** Ignores collisions with layers in the array */
|
|
1896
|
+
ignoreCollisionsWithLayers: string[];
|
|
1897
|
+
/** @internal */
|
|
1898
|
+
shapes: Shape[];
|
|
1899
|
+
constructor(options?: Partial<PolygonColliderOptions>);
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
/**
|
|
1903
|
+
* The type of the rigid body to create:
|
|
1904
|
+
* - Dynamic: This type of body is affected by gravity and velocity.
|
|
1905
|
+
* - Static: This type of body is immovable, is unaffected by velocity and gravity.
|
|
1906
|
+
* @category Components
|
|
1907
|
+
* @public
|
|
1908
|
+
*/
|
|
1909
|
+
declare enum RigidBodyType {
|
|
1910
|
+
Dynamic = 0,
|
|
1911
|
+
Static = 1
|
|
1912
|
+
}
|
|
1913
|
+
/**
|
|
1914
|
+
* RigidBody configuration options
|
|
1915
|
+
* @public
|
|
1916
|
+
* @category Components
|
|
1917
|
+
* @example
|
|
1918
|
+
* ```js
|
|
1919
|
+
const rigidBody = new RigidBody({
|
|
1920
|
+
rigidBodyType: RigidBodyType.Dynamic,
|
|
1921
|
+
gravity: 10,
|
|
1922
|
+
velocity: new Vector2(1, 0),
|
|
1923
|
+
acceleration: new Vector2(1, 0)
|
|
1924
|
+
});
|
|
1925
|
+
* ```
|
|
1926
|
+
* @example
|
|
1927
|
+
* ```js
|
|
1928
|
+
const rigidBody = new RigidBody({
|
|
1929
|
+
rigidBodyType: RigidBodyType.Static,
|
|
1930
|
+
});
|
|
1931
|
+
* ```
|
|
1932
|
+
*/
|
|
1933
|
+
interface RigidBodyOptions {
|
|
1934
|
+
/**
|
|
1935
|
+
* The type of the rigid body to create:
|
|
1936
|
+
* - Dynamic: This type of body is affected by gravity and velocity.
|
|
1937
|
+
* - Static: This type of body is immovable, is unaffected by velocity and gravity.
|
|
1938
|
+
* @public
|
|
1939
|
+
*/
|
|
1940
|
+
type: RigidBodyType;
|
|
1941
|
+
/**
|
|
1942
|
+
* Velocity applied to the x-axis and y-axis expressed in pixels per second. Only for Dynamic bodies
|
|
1943
|
+
* @public
|
|
1944
|
+
*/
|
|
1945
|
+
velocity: Vector2;
|
|
1946
|
+
/**
|
|
1947
|
+
* Gravity expressed in pixels per second squared. Only for Dynamic bodies
|
|
1948
|
+
* @public
|
|
1949
|
+
*/
|
|
1950
|
+
gravity: number;
|
|
1951
|
+
/**
|
|
1952
|
+
* Acceleration expressed in pixels per second squared. Only for Dynamic bodies
|
|
1953
|
+
* @public
|
|
1954
|
+
*/
|
|
1955
|
+
acceleration: Vector2;
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* The RigidBody component puts the entity under simulation of the physics engine, where it will interact with other objects that have a RigidBody.\
|
|
1959
|
+
* There are two types of bodies:
|
|
1960
|
+
* - Dynamic = This type of body is affected by gravity, can be velocity-applied and collides with other rigid bodies.
|
|
1961
|
+
* - Static = This type of body is immovable, no velocity can be applied to it and it is not affected by gravity. It is the body type that consumes the least processing resources.
|
|
1962
|
+
* @public
|
|
1963
|
+
* @category Components
|
|
1964
|
+
* @example
|
|
1965
|
+
* ```js
|
|
1966
|
+
const rigidBody = new RigidBody({
|
|
1967
|
+
rigidBodyType: RigidBodyType.Dynamic,
|
|
1968
|
+
gravity: 10,
|
|
1969
|
+
velocity: new Vector2(1, 0),
|
|
1970
|
+
acceleration: new Vector2(1, 0)
|
|
1971
|
+
});
|
|
1972
|
+
* ```
|
|
1973
|
+
* @example
|
|
1974
|
+
* ```js
|
|
1975
|
+
const rigidBody = new RigidBody({
|
|
1976
|
+
rigidBodyType: RigidBodyType.Static,
|
|
1977
|
+
});
|
|
1978
|
+
* ```
|
|
1979
|
+
*/
|
|
1980
|
+
declare class RigidBody {
|
|
1981
|
+
/**
|
|
1982
|
+
* The type of the rigid body to create:
|
|
1983
|
+
* - Dynamic: This type of body is affected by gravity and velocity.
|
|
1984
|
+
* - Static: This type of body is immovable, is unaffected by velocity and gravity.
|
|
1985
|
+
* @public
|
|
1986
|
+
*/
|
|
1987
|
+
type: RigidBodyType;
|
|
1988
|
+
/**
|
|
1989
|
+
* Velocity applied to the x-axis and y-axis expressed in pixels per second. Only for Dynamic bodies
|
|
1990
|
+
* @public
|
|
1991
|
+
*/
|
|
1992
|
+
velocity: Vector2;
|
|
1993
|
+
/**
|
|
1994
|
+
* Gravity expressed in pixels per second squared. Only for Dynamic bodies
|
|
1995
|
+
* @public
|
|
1996
|
+
*/
|
|
1997
|
+
gravity: number;
|
|
1998
|
+
/**
|
|
1999
|
+
* Acceleration expressed in pixels per second squared. Only for Dynamic bodies
|
|
2000
|
+
* @public
|
|
2001
|
+
*/
|
|
2002
|
+
acceleration: Vector2;
|
|
2003
|
+
constructor(options?: Partial<RigidBodyOptions>);
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
/**
|
|
2007
|
+
* Configuration object for TilemapCollider creation
|
|
2008
|
+
* @public
|
|
2009
|
+
* @category Components
|
|
2010
|
+
* @example
|
|
2011
|
+
* ```js
|
|
2012
|
+
* const tilemapCollider = new TilemapCollider({
|
|
2013
|
+
* composite: true,
|
|
2014
|
+
* offset: new Vector2(),
|
|
2015
|
+
* layer: "CollisionLayer",
|
|
2016
|
+
* physics: true,
|
|
2017
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
2018
|
+
* });
|
|
2019
|
+
* ```
|
|
2020
|
+
*/
|
|
2021
|
+
interface TilemapColliderOptions {
|
|
2022
|
+
/** Generate colliders that represent the outer lines of the tile map */
|
|
2023
|
+
composite: boolean;
|
|
2024
|
+
/** Collision layer */
|
|
2025
|
+
layer: string;
|
|
2026
|
+
/** Ignores collisions with layers in the array */
|
|
2027
|
+
ignoreCollisionsWithLayers: string[];
|
|
2028
|
+
/** X-Y axis offset */
|
|
2029
|
+
offset: Vector2;
|
|
2030
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
2031
|
+
physics: boolean;
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Generates rectangle colliders for the map edge tiles (or lines if composite is TRUE).\
|
|
2035
|
+
* **Limitations:** At the moment, it is not possible to modify the shape of the collider once it has been generated.
|
|
2036
|
+
* @public
|
|
2037
|
+
* @category Components
|
|
2038
|
+
* @example
|
|
2039
|
+
* ```js
|
|
2040
|
+
* const tilemapCollider = new TilemapCollider({
|
|
2041
|
+
* composite: true,
|
|
2042
|
+
* offset: new Vector2(),
|
|
2043
|
+
* layer: "CollisionLayer",
|
|
2044
|
+
* physics: true,
|
|
2045
|
+
* ignoreCollisionsWithLayer: ["IgnoredLayer"]
|
|
2046
|
+
* });
|
|
2047
|
+
* ```
|
|
2048
|
+
*/
|
|
2049
|
+
declare class TilemapCollider implements Collider {
|
|
2050
|
+
/** Generate colliders that represent the outer lines of the tile map */
|
|
2051
|
+
composite: boolean;
|
|
2052
|
+
/** Collision layer */
|
|
2053
|
+
layer: string;
|
|
2054
|
+
/** Ignores collisions with layers in the array */
|
|
2055
|
+
ignoreCollisionsWithLayers: string[];
|
|
2056
|
+
/** X-Y axis offset */
|
|
2057
|
+
offset: Vector2;
|
|
2058
|
+
/** TRUE if this collider interact with rigid bodies */
|
|
2059
|
+
physics: boolean;
|
|
2060
|
+
/** @internal */
|
|
2061
|
+
shapes: Shape[];
|
|
2062
|
+
constructor(options?: Partial<TilemapColliderOptions>);
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
declare enum RenderDataType {
|
|
2066
|
+
Sprite = 0,
|
|
2067
|
+
Text = 1,
|
|
2068
|
+
Tilemap = 2,
|
|
2069
|
+
Mask = 3,
|
|
2070
|
+
Geometric = 4,
|
|
2071
|
+
Video = 5,
|
|
2072
|
+
Shadow = 6
|
|
2073
|
+
}
|
|
2074
|
+
interface CameraData {
|
|
2075
|
+
depth: number;
|
|
2076
|
+
layers: string[];
|
|
2077
|
+
position: Vector2;
|
|
2078
|
+
zoom: number;
|
|
2079
|
+
}
|
|
2080
|
+
interface RenderData {
|
|
2081
|
+
type: RenderDataType;
|
|
2082
|
+
position: Vector2;
|
|
2083
|
+
layer: string;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
/**
|
|
2087
|
+
* Mask shape: Rectangle or Circumference.
|
|
2088
|
+
* @category Components
|
|
2089
|
+
* @public
|
|
2090
|
+
*/
|
|
2091
|
+
declare enum MaskShape {
|
|
2092
|
+
Rectangle = 0,
|
|
2093
|
+
Circumference = 1
|
|
2094
|
+
}
|
|
2095
|
+
interface MaskRenderData extends RenderData {
|
|
2096
|
+
color: string;
|
|
2097
|
+
shape: MaskShape;
|
|
2098
|
+
width: number;
|
|
2099
|
+
height: number;
|
|
2100
|
+
radius: number;
|
|
2101
|
+
rotation: number;
|
|
2102
|
+
opacity: number;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
interface ShadowRenderData extends RenderData {
|
|
2106
|
+
color: string;
|
|
2107
|
+
height: number;
|
|
2108
|
+
opacity: number;
|
|
2109
|
+
rotation: number;
|
|
2110
|
+
width: number;
|
|
2111
|
+
lights: Light[];
|
|
2112
|
+
}
|
|
2113
|
+
/**
|
|
2114
|
+
* Represents a light source
|
|
2115
|
+
* @internal
|
|
2116
|
+
* @example
|
|
2117
|
+
* ```js
|
|
2118
|
+
* const light = {
|
|
2119
|
+
* position: new Vector2(10, 10),
|
|
2120
|
+
* radius: 32,
|
|
2121
|
+
* smooth: true,
|
|
2122
|
+
* intensity: 0.7,
|
|
2123
|
+
* }
|
|
2124
|
+
* ```
|
|
2125
|
+
*/
|
|
2126
|
+
interface Light {
|
|
2127
|
+
/** The position of the light source */
|
|
2128
|
+
position: Vector2;
|
|
2129
|
+
/** The radius of the light source */
|
|
2130
|
+
radius: number;
|
|
2131
|
+
/** If it's TRUE the light will gradually disappear away from the origin point, if FALSE the light will be constant over its entire area. */
|
|
2132
|
+
smooth: boolean;
|
|
2133
|
+
/** The intensity of the light, between 0 and 1 */
|
|
2134
|
+
intensity: number;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
interface SpriteRenderData extends RenderData {
|
|
2138
|
+
image: HTMLImageElement;
|
|
2139
|
+
width: number;
|
|
2140
|
+
height: number;
|
|
2141
|
+
smooth?: boolean;
|
|
2142
|
+
slice?: Slice;
|
|
2143
|
+
flipHorizontally?: boolean;
|
|
2144
|
+
flipVertically?: boolean;
|
|
2145
|
+
rotation?: number;
|
|
2146
|
+
opacity?: number;
|
|
2147
|
+
maskColor?: string;
|
|
2148
|
+
maskColorMix?: number;
|
|
2149
|
+
tintColor?: string;
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Cut the image based on straight coordinates starting from the top left downward.
|
|
2153
|
+
* @category Components
|
|
2154
|
+
* @public
|
|
2155
|
+
*/
|
|
2156
|
+
interface Slice {
|
|
2157
|
+
/** Top left x coordinate */
|
|
2158
|
+
x: number;
|
|
2159
|
+
/** Top left y coordinate */
|
|
2160
|
+
y: number;
|
|
2161
|
+
/** The width to slice */
|
|
2162
|
+
width: number;
|
|
2163
|
+
/** The height to slice */
|
|
2164
|
+
height: number;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
/**
|
|
2168
|
+
* Direction in which the text will be rendered.
|
|
2169
|
+
* @category Components
|
|
2170
|
+
* @public
|
|
2171
|
+
*/
|
|
2172
|
+
declare enum TextOrientation {
|
|
2173
|
+
Center = 0,
|
|
2174
|
+
RightUp = 1,
|
|
2175
|
+
RightDown = 2,
|
|
2176
|
+
RightCenter = 3
|
|
2177
|
+
}
|
|
2178
|
+
interface TextRenderData extends RenderData {
|
|
2179
|
+
font: FontFace | string;
|
|
2180
|
+
text: string;
|
|
2181
|
+
fontSize: number;
|
|
2182
|
+
color: string;
|
|
2183
|
+
lineSeparation: number;
|
|
2184
|
+
letterSpacing: number;
|
|
2185
|
+
orientation: TextOrientation;
|
|
2186
|
+
rotation: number;
|
|
2187
|
+
opacity: number;
|
|
2188
|
+
smooth: boolean;
|
|
2189
|
+
bitmap: {
|
|
2190
|
+
charRanges: number[];
|
|
2191
|
+
fontSize: number;
|
|
2192
|
+
margin: Vector2;
|
|
2193
|
+
spacing: Vector2;
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
/**
|
|
2198
|
+
* Direction in which the tilemap will be rendered.
|
|
2199
|
+
* @category Components
|
|
2200
|
+
* @public
|
|
2201
|
+
*/
|
|
2202
|
+
declare enum TilemapOrientation {
|
|
2203
|
+
Center = 0,
|
|
2204
|
+
RightUp = 1,
|
|
2205
|
+
RightDown = 2,
|
|
2206
|
+
RightCenter = 3
|
|
2207
|
+
}
|
|
2208
|
+
interface TilemapRenderData extends RenderData {
|
|
2209
|
+
tiles: number[];
|
|
2210
|
+
tilemap: {
|
|
2211
|
+
width: number;
|
|
2212
|
+
tileWidth: number;
|
|
2213
|
+
tileHeight: number;
|
|
2214
|
+
height: number;
|
|
2215
|
+
realWidth: number;
|
|
2216
|
+
realHeight: number;
|
|
2217
|
+
};
|
|
2218
|
+
tileset: {
|
|
2219
|
+
image: HTMLImageElement;
|
|
2220
|
+
width: number;
|
|
2221
|
+
tileWidth: number;
|
|
2222
|
+
tileHeight: number;
|
|
2223
|
+
margin?: Vector2;
|
|
2224
|
+
spacing?: Vector2;
|
|
2225
|
+
correction?: Vector2;
|
|
2226
|
+
};
|
|
2227
|
+
smooth?: boolean;
|
|
2228
|
+
flipHorizontal?: boolean;
|
|
2229
|
+
flipVertical?: boolean;
|
|
2230
|
+
rotation?: number;
|
|
2231
|
+
opacity?: number;
|
|
2232
|
+
maskColor?: string;
|
|
2233
|
+
maskColorMix?: number;
|
|
2234
|
+
tintColor?: string;
|
|
2235
|
+
orientation?: TilemapOrientation;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
interface VideoRenderData extends RenderData {
|
|
2239
|
+
video: HTMLVideoElement;
|
|
2240
|
+
width: number;
|
|
2241
|
+
height: number;
|
|
2242
|
+
slice?: Slice;
|
|
2243
|
+
flipHorizontal?: boolean;
|
|
2244
|
+
flipVertical?: boolean;
|
|
2245
|
+
rotation?: number;
|
|
2246
|
+
opacity?: number;
|
|
2247
|
+
maskColor?: string;
|
|
2248
|
+
maskColorMix?: number;
|
|
2249
|
+
tintColor?: string;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
/**
|
|
2253
|
+
* Default render layer
|
|
2254
|
+
* @public
|
|
2255
|
+
* @category Components
|
|
2256
|
+
*/
|
|
2257
|
+
declare const defaultRenderLayer = "Default";
|
|
2258
|
+
/**
|
|
2259
|
+
* @public
|
|
2260
|
+
* @category Components
|
|
2261
|
+
*/
|
|
2262
|
+
interface CameraOptions {
|
|
2263
|
+
layers: string[];
|
|
2264
|
+
zoom: number;
|
|
2265
|
+
depth: number;
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* @public
|
|
2269
|
+
* @category Components
|
|
2270
|
+
*/
|
|
2271
|
+
declare class Camera {
|
|
2272
|
+
/** Layers to be rendered by this camera. Layers are rendered in ascending order */
|
|
2273
|
+
layers: string[];
|
|
2274
|
+
/** Camera zoom. Default value is 1 */
|
|
2275
|
+
zoom: number;
|
|
2276
|
+
/** In case you have more than one camera, the depth value determines which camera is rendered first. The lesser value, the first to render */
|
|
2277
|
+
depth: number;
|
|
2278
|
+
/** @internal */
|
|
2279
|
+
_renderData: CameraData;
|
|
2280
|
+
constructor(options?: Partial<CameraOptions>);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* @public
|
|
2285
|
+
* @category Components
|
|
2286
|
+
*/
|
|
2287
|
+
interface LightRendererOptions {
|
|
2288
|
+
radius: number;
|
|
2289
|
+
smooth: boolean;
|
|
2290
|
+
layer: string;
|
|
2291
|
+
intensity: number;
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* @public
|
|
2295
|
+
* @category Components
|
|
2296
|
+
*/
|
|
2297
|
+
declare class LightRenderer {
|
|
2298
|
+
/** Light radius */
|
|
2299
|
+
radius: number;
|
|
2300
|
+
/** Smooth */
|
|
2301
|
+
smooth: boolean;
|
|
2302
|
+
/** Shadow render layer */
|
|
2303
|
+
layer: string;
|
|
2304
|
+
/** Light intensitry between 0 and 1 */
|
|
2305
|
+
intensity: number;
|
|
2306
|
+
/** @internal */
|
|
2307
|
+
_boundingBox: Rectangle;
|
|
2308
|
+
constructor(options?: Partial<LightRendererOptions>);
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
/**
|
|
2312
|
+
* @public
|
|
2313
|
+
* @category Components
|
|
2314
|
+
*/
|
|
2315
|
+
interface MaskRendererOptions {
|
|
2316
|
+
shape: MaskShape;
|
|
2317
|
+
color: string;
|
|
2318
|
+
width: number;
|
|
2319
|
+
height: number;
|
|
2320
|
+
radius: number;
|
|
2321
|
+
offset: Vector2;
|
|
2322
|
+
rotation: number;
|
|
2323
|
+
opacity: number;
|
|
2324
|
+
layer: string;
|
|
2325
|
+
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Renders a filled shape (rectangle or circumference)
|
|
2328
|
+
* @public
|
|
2329
|
+
* @category Components
|
|
2330
|
+
* @example
|
|
2331
|
+
* ```js
|
|
2332
|
+
* maskRenderer.shape = MaskShape.Rectangle;
|
|
2333
|
+
* maskRenderer.width = 32;
|
|
2334
|
+
* maskRenderer.height = 32;
|
|
2335
|
+
* maskRenderer.color = "#000000";
|
|
2336
|
+
* maskRenderer.offset = new Vector2(0, 0);
|
|
2337
|
+
* maskRenderer.rotation = 0;
|
|
2338
|
+
* maskRenderer.opacity = 1;
|
|
2339
|
+
* maskRenderer.layer = "Default";
|
|
2340
|
+
* ```
|
|
2341
|
+
* @example
|
|
2342
|
+
* ```js
|
|
2343
|
+
* maskRenderer.shape = MaskShape.Circumference;
|
|
2344
|
+
* maskRenderer.radius = 16;
|
|
2345
|
+
* maskRenderer.color = "#000000";
|
|
2346
|
+
* maskRenderer.offset = new Vector2(0, 0);
|
|
2347
|
+
* maskRenderer.opacity = 1;
|
|
2348
|
+
* maskRenderer.layer = "Default";
|
|
2349
|
+
* ```
|
|
2350
|
+
*/
|
|
2351
|
+
declare class MaskRenderer {
|
|
2352
|
+
/** Mask shape: Rectangle or Circumference */
|
|
2353
|
+
shape: MaskShape;
|
|
2354
|
+
/** Mask width in pixels */
|
|
2355
|
+
width: number;
|
|
2356
|
+
/** Mask height in pixels */
|
|
2357
|
+
height: number;
|
|
2358
|
+
/** Mask radius in pixels (only for circumference) */
|
|
2359
|
+
radius: number;
|
|
2360
|
+
/** The color of the mask */
|
|
2361
|
+
color: string;
|
|
2362
|
+
/** X-axis and Y-axis offset */
|
|
2363
|
+
offset: Vector2;
|
|
2364
|
+
/** Mask rotation in radians */
|
|
2365
|
+
rotation: number;
|
|
2366
|
+
/** Change the opacity between 1 and 0 */
|
|
2367
|
+
opacity: number;
|
|
2368
|
+
/** The render layer */
|
|
2369
|
+
layer: string;
|
|
2370
|
+
/** @internal */
|
|
2371
|
+
_renderData: MaskRenderData;
|
|
2372
|
+
constructor(options?: Partial<MaskRendererOptions>);
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
/**
|
|
2376
|
+
* @public
|
|
2377
|
+
* @category Components
|
|
2378
|
+
*/
|
|
2379
|
+
interface ShadowRendererOptions {
|
|
2380
|
+
width: number;
|
|
2381
|
+
height: number;
|
|
2382
|
+
color: string;
|
|
2383
|
+
opacity: number;
|
|
2384
|
+
layer: string;
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* @public
|
|
2388
|
+
* @category Components
|
|
2389
|
+
*/
|
|
2390
|
+
declare class ShadowRenderer {
|
|
2391
|
+
/** Shadow width */
|
|
2392
|
+
width: number;
|
|
2393
|
+
/** Shadow height */
|
|
2394
|
+
height: number;
|
|
2395
|
+
/** Shadow color */
|
|
2396
|
+
color: string;
|
|
2397
|
+
/** Shadow opacity between 0 and 1 */
|
|
2398
|
+
opacity: number;
|
|
2399
|
+
/** The render layer */
|
|
2400
|
+
layer: string;
|
|
2401
|
+
/** @internal */
|
|
2402
|
+
_boundingBox: Rectangle;
|
|
2403
|
+
/** @internal */
|
|
2404
|
+
_renderData: ShadowRenderData;
|
|
2405
|
+
constructor(options?: Partial<ShadowRendererOptions>);
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
/**
|
|
2409
|
+
* @public
|
|
2410
|
+
* @category Components
|
|
2411
|
+
*/
|
|
2412
|
+
interface SpriteRendererOptions {
|
|
2413
|
+
image: HTMLImageElement;
|
|
2414
|
+
layer: string;
|
|
2415
|
+
slice: Slice;
|
|
2416
|
+
smooth: boolean;
|
|
2417
|
+
offset: Vector2;
|
|
2418
|
+
flipHorizontally: boolean;
|
|
2419
|
+
flipVertically: boolean;
|
|
2420
|
+
rotation: number;
|
|
2421
|
+
opacity: number;
|
|
2422
|
+
maskColor: string;
|
|
2423
|
+
maskColorMix: number;
|
|
2424
|
+
tintColor: string;
|
|
2425
|
+
scale: Vector2;
|
|
2426
|
+
width: number;
|
|
2427
|
+
height: number;
|
|
2428
|
+
}
|
|
2429
|
+
/**
|
|
2430
|
+
* @public
|
|
2431
|
+
* @category Components
|
|
2432
|
+
*/
|
|
2433
|
+
declare class SpriteRenderer {
|
|
2434
|
+
/** The render layer */
|
|
2435
|
+
layer: string;
|
|
2436
|
+
/** The image to render */
|
|
2437
|
+
image: HTMLImageElement;
|
|
2438
|
+
/** Cut the image based on straight coordinates starting from the top left downward */
|
|
2439
|
+
slice?: Slice;
|
|
2440
|
+
/** TRUE for smooth pixels (not recommended for pixel art) */
|
|
2441
|
+
smooth: boolean;
|
|
2442
|
+
/** X-axis and Y-axis offset */
|
|
2443
|
+
offset: Vector2;
|
|
2444
|
+
/** Flip the image horizontally */
|
|
2445
|
+
flipHorizontally: boolean;
|
|
2446
|
+
/** Flip the image vertically */
|
|
2447
|
+
flipVertically: boolean;
|
|
2448
|
+
/** Image rotation in radians */
|
|
2449
|
+
rotation: number;
|
|
2450
|
+
/** Change the opacity between 1 and 0 */
|
|
2451
|
+
opacity: number;
|
|
2452
|
+
/** Define a mask color for the image */
|
|
2453
|
+
maskColor: string;
|
|
2454
|
+
/** Define the opacity of the mask color between 1 and 0 */
|
|
2455
|
+
maskColorMix: number;
|
|
2456
|
+
/** Define a color for tinting the sprite image */
|
|
2457
|
+
tintColor: string;
|
|
2458
|
+
/** Scale the image based on a vector */
|
|
2459
|
+
scale: Vector2;
|
|
2460
|
+
/** Overwrite the original image width */
|
|
2461
|
+
width: number;
|
|
2462
|
+
/** Overwrite the original image height */
|
|
2463
|
+
height: number;
|
|
2464
|
+
/** @internal */
|
|
2465
|
+
_renderData: SpriteRenderData;
|
|
2466
|
+
constructor(options?: Partial<SpriteRendererOptions>);
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* @public
|
|
2471
|
+
* @category Components
|
|
2472
|
+
*/
|
|
2473
|
+
interface TextRendererOptions {
|
|
2474
|
+
layer: string;
|
|
2475
|
+
text: string;
|
|
2476
|
+
font: FontFace | string;
|
|
2477
|
+
fontSize: number;
|
|
2478
|
+
width: number;
|
|
2479
|
+
height: number;
|
|
2480
|
+
offset: Vector2;
|
|
2481
|
+
color: string;
|
|
2482
|
+
lineSeparation: number;
|
|
2483
|
+
letterSpacing: number;
|
|
2484
|
+
charRanges: number[];
|
|
2485
|
+
smooth: boolean;
|
|
2486
|
+
rotation: number;
|
|
2487
|
+
opacity: number;
|
|
2488
|
+
orientation: TextOrientation;
|
|
2489
|
+
bitmapMargin: Vector2;
|
|
2490
|
+
bitmapSpacing: Vector2;
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* The TextRenderer component allows to render text using font families, colors, and other configuration options.
|
|
2494
|
+
* @public
|
|
2495
|
+
* @category Components
|
|
2496
|
+
* @example
|
|
2497
|
+
* ```js
|
|
2498
|
+
* textRenderer.layer: "default";
|
|
2499
|
+
* textRenderer.text: "Hello world!";
|
|
2500
|
+
* textRenderer.font: "Arial";
|
|
2501
|
+
* textRenderer.fontSize: 16;
|
|
2502
|
+
* textRenderer.width: 160;
|
|
2503
|
+
* textRenderer.height: 16;
|
|
2504
|
+
* textRenderer.color: "#000000";
|
|
2505
|
+
* textRenderer.offset: new Vector2();
|
|
2506
|
+
* textRenderer.lineSeparation: 0;
|
|
2507
|
+
* textRenderer.letterSpacing: 0;
|
|
2508
|
+
* textRenderer.charRanges: [32, 126, 161, 255];
|
|
2509
|
+
* textRenderer.smooth: false;
|
|
2510
|
+
* textRenderer.rotation: 0;
|
|
2511
|
+
* textRenderer.opacity: 1;
|
|
2512
|
+
* textRenderer.orientation: TextOrientation.RightDown;
|
|
2513
|
+
* textRenderer.bitmapMargin: new Vector2();
|
|
2514
|
+
* textRenderer.bitmapSpacing: new Vector2();
|
|
2515
|
+
* ```
|
|
2516
|
+
*/
|
|
2517
|
+
declare class TextRenderer {
|
|
2518
|
+
/** The render layer */
|
|
2519
|
+
layer: string;
|
|
2520
|
+
/** The text to render */
|
|
2521
|
+
text: string;
|
|
2522
|
+
/** The font family to use */
|
|
2523
|
+
font: FontFace | string;
|
|
2524
|
+
/** The size of the font in pixels. */
|
|
2525
|
+
fontSize: number;
|
|
2526
|
+
/** The width of the invisible box where the text is rendered */
|
|
2527
|
+
width: number;
|
|
2528
|
+
/** The height of the invisible box where the text is rendered */
|
|
2529
|
+
height: number;
|
|
2530
|
+
/** X-axis and Y-axis offset */
|
|
2531
|
+
offset: Vector2;
|
|
2532
|
+
/** The text color */
|
|
2533
|
+
color: string;
|
|
2534
|
+
/** The separation between lines in pixels */
|
|
2535
|
+
lineSeparation: number;
|
|
2536
|
+
/** The space between chars in pixels */
|
|
2537
|
+
letterSpacing: number;
|
|
2538
|
+
/** Range of characters covered by the component defined in number pairs.
|
|
2539
|
+
* The default value is [32, 126, 161, 255], this means that the component
|
|
2540
|
+
* will render characters from 32 to 126 and from 161 to 255. */
|
|
2541
|
+
charRanges: number[];
|
|
2542
|
+
/** Smoothing pixels (not recommended for bitmap fonts) */
|
|
2543
|
+
smooth: boolean;
|
|
2544
|
+
/** Text rotation in radians */
|
|
2545
|
+
rotation: number;
|
|
2546
|
+
/** Change the opacity between 1 and 0 */
|
|
2547
|
+
opacity: number;
|
|
2548
|
+
/** Direction in which the text will be rendered. */
|
|
2549
|
+
orientation: TextOrientation;
|
|
2550
|
+
/** Margin in pixels to correct badly sliced characters. */
|
|
2551
|
+
bitmapMargin: Vector2;
|
|
2552
|
+
/** Spacing in pixels to correct badly sliced characters. */
|
|
2553
|
+
bitmapSpacing: Vector2;
|
|
2554
|
+
/** @internal */
|
|
2555
|
+
_renderData: TextRenderData;
|
|
2556
|
+
constructor(options?: Partial<TextRendererOptions>);
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
/**
|
|
2560
|
+
* @public
|
|
2561
|
+
* @category Components
|
|
2562
|
+
*/
|
|
2563
|
+
interface TilemapRendererOptions {
|
|
2564
|
+
layer: string;
|
|
2565
|
+
tileset: Tileset;
|
|
2566
|
+
data: number[];
|
|
2567
|
+
chunks: Chunk[];
|
|
2568
|
+
width: number;
|
|
2569
|
+
height: number;
|
|
2570
|
+
tileWidth: number;
|
|
2571
|
+
tileHeight: number;
|
|
2572
|
+
tintColor: string;
|
|
2573
|
+
opacity: number;
|
|
2574
|
+
smooth: boolean;
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* The TilemapRenderer component allows you to render a tile map defined by an array of tile ids, using an instance of the TileSet object.
|
|
2578
|
+
* @public
|
|
2579
|
+
* @category Components
|
|
2580
|
+
*/
|
|
2581
|
+
declare class TilemapRenderer {
|
|
2582
|
+
/** The render layer */
|
|
2583
|
+
layer: string;
|
|
2584
|
+
/** The Tileset instance */
|
|
2585
|
+
tileset: Tileset;
|
|
2586
|
+
/** Array of tiles. ID 0 (zero) represents empty space.*/
|
|
2587
|
+
data: number[];
|
|
2588
|
+
/** Array of tile data split into chunks */
|
|
2589
|
+
chunks: Chunk[];
|
|
2590
|
+
/** The width of the tilemap (in tiles) */
|
|
2591
|
+
width: number;
|
|
2592
|
+
/** The height of the tilemap (in tiles) */
|
|
2593
|
+
height: number;
|
|
2594
|
+
/** The width of the tile to render */
|
|
2595
|
+
tileWidth: number;
|
|
2596
|
+
/** The height of the tile to render */
|
|
2597
|
+
tileHeight: number;
|
|
2598
|
+
/** Define a color for tinting the tiles */
|
|
2599
|
+
tintColor: string;
|
|
2600
|
+
/** Change the opacity between 1 and 0 */
|
|
2601
|
+
opacity: number;
|
|
2602
|
+
/** TRUE for smooth pixels (not recommended for pixel art) */
|
|
2603
|
+
smooth: boolean;
|
|
2604
|
+
/** @internal */
|
|
2605
|
+
_processed: boolean;
|
|
2606
|
+
/** @internal */
|
|
2607
|
+
_renderData: TilemapRenderData[];
|
|
2608
|
+
constructor(options?: Partial<TilemapRendererOptions>);
|
|
2609
|
+
}
|
|
2610
|
+
/**
|
|
2611
|
+
* Tileset configuration to be used with the TilemapRenderer
|
|
2612
|
+
* @public
|
|
2613
|
+
* @category Components
|
|
2614
|
+
*/
|
|
2615
|
+
type Tileset = {
|
|
2616
|
+
/** The tileset image element */
|
|
2617
|
+
image: HTMLImageElement;
|
|
2618
|
+
width: number;
|
|
2619
|
+
tileWidth: number;
|
|
2620
|
+
tileHeight: number;
|
|
2621
|
+
/** Margin of the tile in pixels (space in the top and the left) */
|
|
2622
|
+
margin?: Vector2;
|
|
2623
|
+
/** Spacing of the tile in pixels (space in the bottom and the right) */
|
|
2624
|
+
spacing?: Vector2;
|
|
2625
|
+
};
|
|
2626
|
+
/**
|
|
2627
|
+
* Chunk of tile data
|
|
2628
|
+
* @public
|
|
2629
|
+
* @category Components
|
|
2630
|
+
*/
|
|
2631
|
+
type Chunk = {
|
|
2632
|
+
/** Array of tiles. ID 0 (zero) represents empty space.*/
|
|
2633
|
+
data: number[];
|
|
2634
|
+
x: number;
|
|
2635
|
+
y: number;
|
|
2636
|
+
/** Chunk width (in tails) */
|
|
2637
|
+
width: number;
|
|
2638
|
+
/** Chunk height (in tails) */
|
|
2639
|
+
height: number;
|
|
2640
|
+
};
|
|
2641
|
+
|
|
2642
|
+
/**
|
|
2643
|
+
* @public
|
|
2644
|
+
* @category Components
|
|
2645
|
+
*/
|
|
2646
|
+
interface VideoRendererOptions {
|
|
2647
|
+
video: HTMLVideoElement;
|
|
2648
|
+
width: number;
|
|
2649
|
+
height: number;
|
|
2650
|
+
offset: Vector2;
|
|
2651
|
+
rotation: number;
|
|
2652
|
+
flipHorizontally: boolean;
|
|
2653
|
+
flipVertically: boolean;
|
|
2654
|
+
opacity: number;
|
|
2655
|
+
maskColor: string;
|
|
2656
|
+
maskColorMix: number;
|
|
2657
|
+
tintColor: string;
|
|
2658
|
+
layer: string;
|
|
2659
|
+
slice: Slice;
|
|
2660
|
+
loop: boolean;
|
|
2661
|
+
volume: number;
|
|
2662
|
+
play: boolean;
|
|
2663
|
+
pause: boolean;
|
|
2664
|
+
}
|
|
2665
|
+
/**
|
|
2666
|
+
* The VideoRenderer component plays and renders a video element,
|
|
2667
|
+
* and allows configuring options such as its dimensions, coloring, etc.
|
|
2668
|
+
* @public
|
|
2669
|
+
* @category Components
|
|
2670
|
+
* @example
|
|
2671
|
+
* ```js
|
|
2672
|
+
* videoRenderer.video = this.assetManager.getVideo("video.mp4");
|
|
2673
|
+
* videoRenderer.width = 1920;
|
|
2674
|
+
* videoRenderer.height = 1080;
|
|
2675
|
+
* videoRenderer.offset = new Vector2(0, 0);
|
|
2676
|
+
* videoRenderer.flipHorizontally = false;
|
|
2677
|
+
* videoRenderer.flipVertically = false;
|
|
2678
|
+
* videoRenderer.rotation = 0;
|
|
2679
|
+
* videoRenderer.opacity = 1;
|
|
2680
|
+
* videoRenderer.maskColor = "#FF0000";
|
|
2681
|
+
* videoRenderer.maskColorMix = 0;
|
|
2682
|
+
* videoRenderer.tintColor = "#00FF00";
|
|
2683
|
+
* videoRenderer.layer = "Default";
|
|
2684
|
+
* videoRenderer.slice = {x: 0, y:0, width: 1920, height: 1080};
|
|
2685
|
+
* videoRenderer.volume = 1;
|
|
2686
|
+
* videoRenderer.loop = false;
|
|
2687
|
+
* videoRenderer.play = true;
|
|
2688
|
+
* videoRenderer.pause = false;
|
|
2689
|
+
* ```
|
|
2690
|
+
*/
|
|
2691
|
+
declare class VideoRenderer {
|
|
2692
|
+
/**The video element to render */
|
|
2693
|
+
video: HTMLVideoElement;
|
|
2694
|
+
/** Overwrite the original video width */
|
|
2695
|
+
width: number;
|
|
2696
|
+
/** Overwrite the original video height */
|
|
2697
|
+
height: number;
|
|
2698
|
+
/** X-axis and Y-axis offset */
|
|
2699
|
+
offset: Vector2;
|
|
2700
|
+
/** Video rotation (degrees or radians) */
|
|
2701
|
+
rotation: number;
|
|
2702
|
+
/** Flip the video horizontally */
|
|
2703
|
+
flipHorizontally: boolean;
|
|
2704
|
+
/** Flip the video vertically */
|
|
2705
|
+
flipVertically: boolean;
|
|
2706
|
+
/** Change the opacity between 1 and 0 */
|
|
2707
|
+
opacity: number;
|
|
2708
|
+
/** Define a mask color for the video */
|
|
2709
|
+
maskColor: string;
|
|
2710
|
+
/** Define the opacity of the mask color between 1 and 0 */
|
|
2711
|
+
maskColorMix: number;
|
|
2712
|
+
/** Define a color for tinting the video */
|
|
2713
|
+
tintColor: string;
|
|
2714
|
+
/** The render layer */
|
|
2715
|
+
layer: string;
|
|
2716
|
+
/** Cut the video based on straight coordinates starting from the top left downward */
|
|
2717
|
+
slice?: Slice;
|
|
2718
|
+
/** TRUE to play the video in loop */
|
|
2719
|
+
loop: boolean;
|
|
2720
|
+
/** The volume of the video (between 1 and 0) */
|
|
2721
|
+
volume: number;
|
|
2722
|
+
/** TRUE to play the video. If the video stops playing it becomes FALSE */
|
|
2723
|
+
play: boolean;
|
|
2724
|
+
/** TRUE to pause the video */
|
|
2725
|
+
pause: boolean;
|
|
2726
|
+
/** @internal */
|
|
2727
|
+
_renderData: VideoRenderData;
|
|
2728
|
+
constructor(options?: Partial<VideoRendererOptions>);
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
/**
|
|
2732
|
+
* It represents a connected gamepad and has the information of all its buttons and axes..
|
|
2733
|
+
* @public
|
|
2734
|
+
* @category Input
|
|
2735
|
+
* @example
|
|
2736
|
+
* ```js
|
|
2737
|
+
* const gamepad = this.inputManager.gamepads[0];
|
|
2738
|
+
*
|
|
2739
|
+
* if (gamepad.dpadAxes.x > 1) {
|
|
2740
|
+
* // if the depad x-axis is pressed to the right, do some action
|
|
2741
|
+
* }
|
|
2742
|
+
*
|
|
2743
|
+
* if (gamepad.rightFace) {
|
|
2744
|
+
* // if the right face button is pressed, do some action
|
|
2745
|
+
* }
|
|
2746
|
+
* ```
|
|
2747
|
+
*/
|
|
2748
|
+
declare class GamepadController {
|
|
2749
|
+
/** @internal */
|
|
2750
|
+
readonly buttons: Map<number, boolean>;
|
|
2751
|
+
/** @internal */
|
|
2752
|
+
readonly axes: Map<number, number>;
|
|
2753
|
+
private readonly _dpadAxes;
|
|
2754
|
+
private readonly _leftStickAxes;
|
|
2755
|
+
private readonly _rightStickAxes;
|
|
2756
|
+
/**
|
|
2757
|
+
* The gamepad id
|
|
2758
|
+
*/
|
|
2759
|
+
id: string;
|
|
2760
|
+
/**
|
|
2761
|
+
* The gamepad index
|
|
2762
|
+
*/
|
|
2763
|
+
index: number;
|
|
2764
|
+
/**
|
|
2765
|
+
* TRUE if the gamepad is connected
|
|
2766
|
+
*/
|
|
2767
|
+
connected: boolean;
|
|
2768
|
+
/**
|
|
2769
|
+
* The values of the d-pad axes represented as a xy vector
|
|
2770
|
+
*/
|
|
2771
|
+
get dpadAxes(): Vector2;
|
|
2772
|
+
/**
|
|
2773
|
+
* The values of the left stick axes represented as a xy vector
|
|
2774
|
+
*/
|
|
2775
|
+
get leftStickAxes(): Vector2;
|
|
2776
|
+
/**
|
|
2777
|
+
* The values of the right stick axes represented as a xy vector
|
|
2778
|
+
*/
|
|
2779
|
+
get rightStickAxes(): Vector2;
|
|
2780
|
+
/**
|
|
2781
|
+
* TRUE if d-pad up is pressed
|
|
2782
|
+
*/
|
|
2783
|
+
get dpadUp(): boolean;
|
|
2784
|
+
/**
|
|
2785
|
+
* TRUE if d-pad down is pressed
|
|
2786
|
+
*/
|
|
2787
|
+
get dpadDown(): boolean;
|
|
2788
|
+
/**
|
|
2789
|
+
* TRUE if d-pad left is pressed
|
|
2790
|
+
*/
|
|
2791
|
+
get dpadLeft(): boolean;
|
|
2792
|
+
/**
|
|
2793
|
+
* TRUE if d-pad right is pressed
|
|
2794
|
+
*/
|
|
2795
|
+
get dpadRight(): boolean;
|
|
2796
|
+
/**
|
|
2797
|
+
* TRUE if bottom face button is pressed (Dual Shock: X. Xbox: A. Nintendo: B)
|
|
2798
|
+
*/
|
|
2799
|
+
get bottomFace(): boolean;
|
|
2800
|
+
/**
|
|
2801
|
+
* TRUE if right face button is pressed (Dual Shock: Square. Xbox: X. Nintendo: Y)
|
|
2802
|
+
*/
|
|
2803
|
+
get rightFace(): boolean;
|
|
2804
|
+
/**
|
|
2805
|
+
* TRUE if left face button is pressed (Dual Shock: Circle. Xbox: B. Nintendo: A)
|
|
2806
|
+
*/
|
|
2807
|
+
get leftFace(): boolean;
|
|
2808
|
+
/**
|
|
2809
|
+
* TRUE if top face button is pressed (Dual Shock: Triangle. Xbox: Y. Nintendo: X)
|
|
2810
|
+
*/
|
|
2811
|
+
get topFace(): boolean;
|
|
2812
|
+
/**
|
|
2813
|
+
* TRUE if left shoulder button is pressed (Dual Shock: L1. Xbox: LB. Nintendo: L)
|
|
2814
|
+
*/
|
|
2815
|
+
get leftShoulder(): boolean;
|
|
2816
|
+
/**
|
|
2817
|
+
* TRUE if right shoulder button is pressed (Dual Shock: R1. Xbox: RB. Nintendo: R)
|
|
2818
|
+
*/
|
|
2819
|
+
get rightShoulder(): boolean;
|
|
2820
|
+
/**
|
|
2821
|
+
* TRUE if left trigger button is pressed (Dual Shock: L2. Xbox: LT. Nintendo: ZL)
|
|
2822
|
+
*/
|
|
2823
|
+
get leftTrigger(): boolean;
|
|
2824
|
+
/**
|
|
2825
|
+
* TRUE if right trigger button is pressed (Dual Shock: R2. Xbox: RT. Nintendo: ZR)
|
|
2826
|
+
*/
|
|
2827
|
+
get rightTrigger(): boolean;
|
|
2828
|
+
/**
|
|
2829
|
+
* TRUE if back button is pressed (a.k.a. select button)
|
|
2830
|
+
*/
|
|
2831
|
+
get back(): boolean;
|
|
2832
|
+
/**
|
|
2833
|
+
* TRUE if start button is pressed (a.k.a. options button)
|
|
2834
|
+
*/
|
|
2835
|
+
get start(): boolean;
|
|
2836
|
+
/**
|
|
2837
|
+
* TRUE if left stick button is pressed
|
|
2838
|
+
*/
|
|
2839
|
+
get leftStickButton(): boolean;
|
|
2840
|
+
/**
|
|
2841
|
+
* TRUE if right stick button is pressed
|
|
2842
|
+
*/
|
|
2843
|
+
get rightStickButton(): boolean;
|
|
2844
|
+
/**
|
|
2845
|
+
* Left stick horizontal axes value
|
|
2846
|
+
*/
|
|
2847
|
+
get leftStickHorizontal(): number;
|
|
2848
|
+
/**
|
|
2849
|
+
* Left stick vertical axes value
|
|
2850
|
+
*/
|
|
2851
|
+
get leftStickVertical(): number;
|
|
2852
|
+
/**
|
|
2853
|
+
* Right stick horizontal axes value
|
|
2854
|
+
*/
|
|
2855
|
+
get rightStickHorizontal(): number;
|
|
2856
|
+
/**
|
|
2857
|
+
* Right stick vertical axes value
|
|
2858
|
+
*/
|
|
2859
|
+
get rightStickVertical(): number;
|
|
2860
|
+
/**
|
|
2861
|
+
* TRUE if any button is pressed
|
|
2862
|
+
*/
|
|
2863
|
+
get anyButtonPressed(): boolean;
|
|
2864
|
+
/**
|
|
2865
|
+
* TRUE if the vibration is on
|
|
2866
|
+
*/
|
|
2867
|
+
vibrating: boolean;
|
|
2868
|
+
/**
|
|
2869
|
+
* @internal
|
|
2870
|
+
*/
|
|
2871
|
+
vibrationInput: VibrationInput;
|
|
2872
|
+
/**
|
|
2873
|
+
* Turns on the gamepad vibration
|
|
2874
|
+
* @param duration The duration of the effect in milliseconds
|
|
2875
|
+
* @param weakMagnitude Rumble intensity of the high-frequency (weak) rumble motors, normalized to the range between 0.0 and 1.0
|
|
2876
|
+
* @param strongMagnitude Rumble intensity of the low-frequency (strong) rumble motors, normalized to the range between 0.0 and 1.0
|
|
2877
|
+
* @param startDelay The delay in milliseconds before the effect is started
|
|
2878
|
+
*/
|
|
2879
|
+
vibrate(duration?: number, weakMagnitude?: number, strongMagnitude?: number, startDelay?: number): void;
|
|
2880
|
+
}
|
|
2881
|
+
/** @internal */
|
|
2882
|
+
type VibrationInput = {
|
|
2883
|
+
duration: number;
|
|
2884
|
+
weakMagnitude: number;
|
|
2885
|
+
strongMagnitude: number;
|
|
2886
|
+
startDelay: number;
|
|
2887
|
+
};
|
|
2888
|
+
|
|
2889
|
+
/**
|
|
2890
|
+
* Contains the keyboard information in the last frame.
|
|
2891
|
+
* It uses the **code** property of the **js keyboard event**.
|
|
2892
|
+
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
2893
|
+
* @public
|
|
2894
|
+
* @category Input
|
|
2895
|
+
* @example
|
|
2896
|
+
* ```js
|
|
2897
|
+
* const keyboard = this.inputManager.keyboard;
|
|
2898
|
+
*
|
|
2899
|
+
* if (keyboard.isPressed("ArrowRight")) {
|
|
2900
|
+
* // if the right arrow key is pressed, do some action
|
|
2901
|
+
* }
|
|
2902
|
+
*
|
|
2903
|
+
* if (keyboard.orPressed("Enter", "Space")) {
|
|
2904
|
+
* // if the enter key or space key are pressed, do some action
|
|
2905
|
+
* }
|
|
2906
|
+
*
|
|
2907
|
+
* if (keyboard.andPressed("ControlLeft", "KeyC")) {
|
|
2908
|
+
* // if the left control key and the letter C key are pressed, do some action
|
|
2909
|
+
* }
|
|
2910
|
+
* ```
|
|
2911
|
+
*/
|
|
2912
|
+
declare class Keyboard {
|
|
2913
|
+
/**
|
|
2914
|
+
* The current pressed key codes
|
|
2915
|
+
*/
|
|
2916
|
+
pressedKeys: string[];
|
|
2917
|
+
/**
|
|
2918
|
+
* Returns TRUE if the given key is being pressed.
|
|
2919
|
+
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
2920
|
+
* @param keyCode The code of the key to check
|
|
2921
|
+
* @returns TRUE true for pressed, FALSE instead
|
|
2922
|
+
*/
|
|
2923
|
+
isPressed(keyCode: string): boolean;
|
|
2924
|
+
/**
|
|
2925
|
+
* Returns TRUE if one of the given keys is being pressed.
|
|
2926
|
+
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
2927
|
+
* @param keyCodes The codes of the keys to check
|
|
2928
|
+
* @returns TRUE for pressed, FALSE instead
|
|
2929
|
+
*/
|
|
2930
|
+
orPressed(keyCodes: string[]): boolean;
|
|
2931
|
+
/**
|
|
2932
|
+
* Returns TRUE if all the given keys are being pressed.
|
|
2933
|
+
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
2934
|
+
* @param keyCodes The codes of the keys to check
|
|
2935
|
+
* @returns TRUE for pressed, FALSE instead
|
|
2936
|
+
*/
|
|
2937
|
+
andPressed(keyCodes: string[]): boolean;
|
|
2938
|
+
/**
|
|
2939
|
+
* This method accepts two parameters that will be returned depending on whether the key is pressed or not.
|
|
2940
|
+
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
2941
|
+
* @param keyCode The code of the key to check
|
|
2942
|
+
* @param returnTrue The value to return if the key is pressed
|
|
2943
|
+
* @param returnFalse The value to return if the key is not pressed
|
|
2944
|
+
* @returns The returnTrue for pressed or the returnFalse instead
|
|
2945
|
+
*/
|
|
2946
|
+
isPressedReturn<T>(keyCode: string, returnTrue: T, returnFalse: T): T;
|
|
2947
|
+
/**
|
|
2948
|
+
* This method accepts two parameters that will be returned depending on whether one of the given keys is being pressed.
|
|
2949
|
+
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
2950
|
+
* @param keyCodes The codes of the keys to check
|
|
2951
|
+
* @param returnTrue The value to return if the key is pressed
|
|
2952
|
+
* @param returnFalse The value to return if the key is not pressed
|
|
2953
|
+
* @returns The returnTrue for pressed or the returnFalse instead
|
|
2954
|
+
*/
|
|
2955
|
+
orPressedReturn<T>(keyCodes: string[], returnTrue: T, returnFalse: T): T;
|
|
2956
|
+
/**
|
|
2957
|
+
* This method accepts two parameters that will be returned depending on whether all the given keys are being pressed.
|
|
2958
|
+
* @see [KeyboardEvent: code property](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
|
|
2959
|
+
* @param keyCodes The codes of the keys to check
|
|
2960
|
+
* @param returnTrue The value to return if the key is pressed
|
|
2961
|
+
* @param returnFalse The value to return if the key is not pressed
|
|
2962
|
+
* @returns The returnTrue for pressed or the returnFalse instead
|
|
2963
|
+
*/
|
|
2964
|
+
andPressedReturn<T>(keyCodes: string[], returnTrue: T, returnFalse: T): T;
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
/**
|
|
2968
|
+
* Contains the mouse information in the last frame
|
|
2969
|
+
* @public
|
|
2970
|
+
* @category Input
|
|
2971
|
+
* @example
|
|
2972
|
+
* ```js
|
|
2973
|
+
* const mouse = this.inputManager.mouse;
|
|
2974
|
+
*
|
|
2975
|
+
* if (mouse.positionInViewport.y < 0 && mouse.leftButtonPressed) {
|
|
2976
|
+
* // if the mouse pointer is below the middle of the screen and left click, do something
|
|
2977
|
+
* }
|
|
2978
|
+
* ```
|
|
2979
|
+
*/
|
|
2980
|
+
declare class Mouse {
|
|
2981
|
+
/**
|
|
2982
|
+
* TRUE if the left button is being pressed
|
|
2983
|
+
*/
|
|
2984
|
+
leftButtonPressed: boolean;
|
|
2985
|
+
/**
|
|
2986
|
+
* TRUE if the scroll button is being pressed
|
|
2987
|
+
*/
|
|
2988
|
+
scrollButtonPressed: boolean;
|
|
2989
|
+
/**
|
|
2990
|
+
* TRUE if the right button is beign pressed
|
|
2991
|
+
*/
|
|
2992
|
+
rightButtonPressed: boolean;
|
|
2993
|
+
/**
|
|
2994
|
+
* The position of the pointer in the screen view port
|
|
2995
|
+
*/
|
|
2996
|
+
positionInViewport: Vector2;
|
|
2997
|
+
/**
|
|
2998
|
+
* TRUE if the mouse moved during the last frame
|
|
2999
|
+
*/
|
|
3000
|
+
hasMoved: boolean;
|
|
3001
|
+
/**
|
|
3002
|
+
* The scroll amount of the mouse wheel
|
|
3003
|
+
*/
|
|
3004
|
+
wheelScroll: Vector2;
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
/**
|
|
3008
|
+
* The information about one interaction with the screen
|
|
3009
|
+
* @public
|
|
3010
|
+
* @category Input
|
|
3011
|
+
*/
|
|
3012
|
+
interface TouchInteraction {
|
|
3013
|
+
/** The interaction position on the screen */
|
|
3014
|
+
positionInViewport: Vector2;
|
|
3015
|
+
/** The area of the interaction represented as a radius of the ellipse */
|
|
3016
|
+
radius: Vector2;
|
|
3017
|
+
}
|
|
3018
|
+
/**
|
|
3019
|
+
* Contains the information about the touch screen interaction
|
|
3020
|
+
* @public
|
|
3021
|
+
* @category Input
|
|
3022
|
+
* @example
|
|
3023
|
+
* ```js
|
|
3024
|
+
* const touch = this.inputController.touch;
|
|
3025
|
+
*
|
|
3026
|
+
* if (touch.touching) {
|
|
3027
|
+
* const interaction = touch.interactions[0];
|
|
3028
|
+
* }
|
|
3029
|
+
* ```
|
|
3030
|
+
*/
|
|
3031
|
+
declare class TouchScreen {
|
|
3032
|
+
/**
|
|
3033
|
+
* TRUE if there is an interaction with the screen
|
|
3034
|
+
*/
|
|
3035
|
+
touching: boolean;
|
|
3036
|
+
/**
|
|
3037
|
+
* The information about the interactions with the screen
|
|
3038
|
+
*/
|
|
3039
|
+
interactions: TouchInteraction[];
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
/**
|
|
3043
|
+
* Manages the input sources: Keyboard, Mouse, Gamepad, TouchScreen.
|
|
3044
|
+
* @public
|
|
3045
|
+
* @category Managers
|
|
3046
|
+
*/
|
|
3047
|
+
declare class InputManager {
|
|
3048
|
+
/** Manages mouse information. */
|
|
3049
|
+
readonly keyboard: Keyboard;
|
|
3050
|
+
/** Manages keyboard information. */
|
|
3051
|
+
readonly mouse: Mouse;
|
|
3052
|
+
/** Manages touch screen information. */
|
|
3053
|
+
readonly touchScreen: TouchScreen;
|
|
3054
|
+
/** Manages gamepads information. */
|
|
3055
|
+
readonly gamepads: GamepadController[];
|
|
3056
|
+
constructor();
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
/**
|
|
3060
|
+
* Manages the properties associated with time.
|
|
3061
|
+
* @public
|
|
3062
|
+
* @category Managers
|
|
3063
|
+
* @example
|
|
3064
|
+
* ```js
|
|
3065
|
+
* // using deltaTime to increment a timer
|
|
3066
|
+
* this.timer += this.timeManager.deltaTime;
|
|
3067
|
+
*
|
|
3068
|
+
* // using physicsDeltaTime within a physics component to move the object it belongs to
|
|
3069
|
+
* this.transform.position.x += speed * this.timeManager.physicsDeltaTime;
|
|
3070
|
+
*
|
|
3071
|
+
* // stop all time-related interactions by setting the scale to zero
|
|
3072
|
+
* this.timeManager.timeScale = 0;
|
|
3073
|
+
* ```
|
|
3074
|
+
*/
|
|
3075
|
+
declare class TimeManager {
|
|
3076
|
+
/** @internal */
|
|
3077
|
+
readonly fixedGameFramerate: number;
|
|
3078
|
+
/** @internal */
|
|
3079
|
+
readonly fixedGameDeltaTime: number;
|
|
3080
|
+
/** @internal */
|
|
3081
|
+
readonly fixedPhysicsFramerate: number;
|
|
3082
|
+
/** @internal */
|
|
3083
|
+
readonly fixedPhysicsDeltaTime: number;
|
|
3084
|
+
/**
|
|
3085
|
+
* The scale on which time passes. The default value is 1.\
|
|
3086
|
+
* For example, if set to 2, the time will run at twice the speed.\
|
|
3087
|
+
* If set to 0.5, it will run at half the speed.\
|
|
3088
|
+
* If set to 0, everything associated with the time will stop.
|
|
3089
|
+
*/
|
|
3090
|
+
timeScale: number;
|
|
3091
|
+
/** The time difference, in seconds, between the last frame of and the current frame recorded by the browser. */
|
|
3092
|
+
browserDeltaTime: number;
|
|
3093
|
+
/** The time difference, in seconds, between the last frame and the current frame, unaffected by the scale. */
|
|
3094
|
+
unscaledDeltaTime: number;
|
|
3095
|
+
/** The time difference, in seconds, between the last physics frame and the current one, unaffected by the scale. */
|
|
3096
|
+
unscaledPhysicsDeltaTime: number;
|
|
3097
|
+
private maxDeltaTime;
|
|
3098
|
+
private thenForGame;
|
|
3099
|
+
private thenForPhysics;
|
|
3100
|
+
private thenForRender;
|
|
3101
|
+
/** The time difference, in seconds, between the last frame and the current frame. */
|
|
3102
|
+
get deltaTime(): number;
|
|
3103
|
+
/** The time difference, in seconds, between the last physics frame and the current one. */
|
|
3104
|
+
get physicsDeltaTime(): number;
|
|
3105
|
+
/** The browser delta time affected by time scale. */
|
|
3106
|
+
get renderDeltaTime(): number;
|
|
3107
|
+
constructor({ physicsFramerate }: GameConfig);
|
|
3108
|
+
/** @internal */
|
|
3109
|
+
updateForRender(time: number): void;
|
|
3110
|
+
/** @internal */
|
|
3111
|
+
updateForGame(time: number): void;
|
|
3112
|
+
/** @internal */
|
|
3113
|
+
updateForPhysics(time: number): void;
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
/**
|
|
3117
|
+
* Abstract class which can be used to create Systems.\
|
|
3118
|
+
* It includes the following dependencies: EntityManager, AssetManager, SceneManager, TimeManager, InputManager, CollisionRepository.
|
|
3119
|
+
* @public
|
|
3120
|
+
* @category Core
|
|
3121
|
+
* @example
|
|
3122
|
+
* ```javascript
|
|
3123
|
+
* class SomeSystem extends GameSystem {
|
|
3124
|
+
* onUpdate() {
|
|
3125
|
+
* const result = this.entityManager.search(SomeComponent);
|
|
3126
|
+
* }
|
|
3127
|
+
* }
|
|
3128
|
+
* ```
|
|
3129
|
+
*/
|
|
3130
|
+
declare abstract class GameSystem implements System {
|
|
3131
|
+
protected readonly entityManager: EntityManager;
|
|
3132
|
+
protected readonly assetManager: AssetManager;
|
|
3133
|
+
protected readonly sceneManager: SceneManager;
|
|
3134
|
+
protected readonly timeManager: TimeManager;
|
|
3135
|
+
protected readonly inputManager: InputManager;
|
|
3136
|
+
protected readonly collisionRepository: CollisionRepository;
|
|
3137
|
+
onUpdate(): void;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
/**
|
|
3141
|
+
* Decorator to indicate that the target system will run in the game logic loop.
|
|
3142
|
+
* @public
|
|
3143
|
+
* @category Decorators
|
|
3144
|
+
* @example
|
|
3145
|
+
* ```typescript
|
|
3146
|
+
* @gameLogicSystem()
|
|
3147
|
+
* class SomeSystem {
|
|
3148
|
+
* }
|
|
3149
|
+
* ```
|
|
3150
|
+
*/
|
|
3151
|
+
declare function gameLogicSystem(): (target: SystemType) => void;
|
|
3152
|
+
/**
|
|
3153
|
+
* Decorator to indicate that the target system will run in the physics loop.
|
|
3154
|
+
* @public
|
|
3155
|
+
* @category Decorators
|
|
3156
|
+
* @example
|
|
3157
|
+
* ```typescript
|
|
3158
|
+
* @gamePhysicsSystem()
|
|
3159
|
+
* class SomeSystem {
|
|
3160
|
+
* }
|
|
3161
|
+
* ```
|
|
3162
|
+
*/
|
|
3163
|
+
declare function gamePhysicsSystem(): (target: SystemType) => void;
|
|
3164
|
+
/**
|
|
3165
|
+
* Decorator to indicate that the target system will be executed at the begining of the render loop.
|
|
3166
|
+
* @public
|
|
3167
|
+
* @category Decorators
|
|
3168
|
+
* @example
|
|
3169
|
+
* ```typescript
|
|
3170
|
+
* @gamePreRenderSystem()
|
|
3171
|
+
* class SomeSystem {
|
|
3172
|
+
* }
|
|
3173
|
+
* ```
|
|
3174
|
+
*/
|
|
3175
|
+
declare function gamePreRenderSystem(): (target: SystemType) => void;
|
|
3176
|
+
|
|
3177
|
+
/**
|
|
3178
|
+
* Symbols to be used as dependency identifiers
|
|
3179
|
+
* @public
|
|
3180
|
+
* @category Config
|
|
3181
|
+
*/
|
|
3182
|
+
declare const Symbols: {
|
|
3183
|
+
AssetManager: symbol;
|
|
3184
|
+
CanvasElement: symbol;
|
|
3185
|
+
CollisionRepository: symbol;
|
|
3186
|
+
EntityManager: symbol;
|
|
3187
|
+
GameConfig: symbol;
|
|
3188
|
+
InputManager: symbol;
|
|
3189
|
+
SceneManager: symbol;
|
|
3190
|
+
SystemManager: symbol;
|
|
3191
|
+
TimeManager: symbol;
|
|
3192
|
+
};
|
|
3193
|
+
|
|
3194
|
+
export { Animation, type AnimationSlice, Animator, type AnimatorOptions, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, Children, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, InputManager, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, Parent, Polygon, PolygonCollider, type PolygonColliderOptions, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, Symbols, type System, type SystemGroup, SystemManager, type SystemType, TextOrientation, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, defaultRenderLayer, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, randomFloat, randomInt, range };
|