melonjs 10.5.2 → 10.6.0
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 +4 -6
- package/dist/melonjs.js +4314 -4177
- package/dist/melonjs.min.js +14 -14
- package/dist/melonjs.module.d.ts +242 -267
- package/dist/melonjs.module.js +4646 -4523
- package/package.json +10 -10
- package/src/camera/camera2d.js +11 -10
- package/src/geometries/ellipse.js +1 -1
- package/src/geometries/poly.js +1 -1
- package/src/index.js +1 -1
- package/src/input/pointerevent.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXTileMap.js +1 -1
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/loadingscreen.js +1 -1
- package/src/math/color.js +1 -1
- package/src/math/matrix2.js +2 -2
- package/src/math/matrix3.js +1 -1
- package/src/math/observable_vector2.js +1 -1
- package/src/math/observable_vector3.js +1 -1
- package/src/math/vector2.js +1 -1
- package/src/math/vector3.js +1 -1
- package/src/particles/emitter.js +1 -1
- package/src/physics/body.js +7 -7
- package/src/renderable/colorlayer.js +1 -1
- package/src/renderable/container.js +11 -1
- package/src/renderable/imagelayer.js +1 -1
- package/src/renderable/nineslicesprite.js +6 -3
- package/src/renderable/renderable.js +18 -1
- package/src/renderable/sprite.js +2 -2
- package/src/state/state.js +6 -6
- package/src/system/pooling.js +150 -155
- package/src/text/bitmaptext.js +30 -86
- package/src/text/text.js +82 -145
- package/src/text/textmetrics.js +168 -0
- package/src/text/textstyle.js +14 -0
- package/src/video/canvas/canvas_renderer.js +21 -5
- package/src/video/renderer.js +1 -3
- package/src/video/texture.js +1 -1
- package/src/video/webgl/buffer/vertex.js +0 -3
- package/src/video/webgl/glshader.js +0 -2
- package/src/video/webgl/webgl_renderer.js +46 -19
package/dist/melonjs.module.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export class BitmapText extends Renderable {
|
|
|
17
17
|
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
18
18
|
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
19
19
|
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
20
|
+
* @param {number} [settings.wordWrapWidth] the maximum length in CSS pixel for a single segment of text
|
|
20
21
|
* @param {(string|string[])} [settings.text] a string, or an array of strings
|
|
21
22
|
* @example
|
|
22
23
|
* // Use me.loader.preload or me.loader.load to load assets
|
|
@@ -42,6 +43,7 @@ export class BitmapText extends Renderable {
|
|
|
42
43
|
textBaseline?: string;
|
|
43
44
|
lineHeight?: number;
|
|
44
45
|
anchorPoint?: Vector2d;
|
|
46
|
+
wordWrapWidth?: number;
|
|
45
47
|
text?: (string | string[]);
|
|
46
48
|
});
|
|
47
49
|
/**
|
|
@@ -50,8 +52,6 @@ export class BitmapText extends Renderable {
|
|
|
50
52
|
* @public
|
|
51
53
|
* @type {string}
|
|
52
54
|
* @default "left"
|
|
53
|
-
* @name textAlign
|
|
54
|
-
* @memberof BitmapText
|
|
55
55
|
*/
|
|
56
56
|
public textAlign: string;
|
|
57
57
|
/**
|
|
@@ -60,8 +60,6 @@ export class BitmapText extends Renderable {
|
|
|
60
60
|
* @public
|
|
61
61
|
* @type {string}
|
|
62
62
|
* @default "top"
|
|
63
|
-
* @name textBaseline
|
|
64
|
-
* @memberof BitmapText
|
|
65
63
|
*/
|
|
66
64
|
public textBaseline: string;
|
|
67
65
|
/**
|
|
@@ -70,10 +68,16 @@ export class BitmapText extends Renderable {
|
|
|
70
68
|
* @public
|
|
71
69
|
* @type {number}
|
|
72
70
|
* @default 1.0
|
|
73
|
-
* @name lineHeight
|
|
74
|
-
* @memberof BitmapText
|
|
75
71
|
*/
|
|
76
72
|
public lineHeight: number;
|
|
73
|
+
/**
|
|
74
|
+
* the maximum length in CSS pixel for a single segment of text.
|
|
75
|
+
* (use -1 to disable word wrapping)
|
|
76
|
+
* @public
|
|
77
|
+
* @type {number}
|
|
78
|
+
* @default -1
|
|
79
|
+
*/
|
|
80
|
+
public wordWrapWidth: number;
|
|
77
81
|
/**
|
|
78
82
|
* the text to be displayed
|
|
79
83
|
* @private
|
|
@@ -94,11 +98,9 @@ export class BitmapText extends Renderable {
|
|
|
94
98
|
* @private
|
|
95
99
|
*/
|
|
96
100
|
private fontData;
|
|
101
|
+
metrics: TextMetrics;
|
|
97
102
|
/**
|
|
98
103
|
* change the font settings
|
|
99
|
-
* @name set
|
|
100
|
-
* @memberof BitmapText.prototype
|
|
101
|
-
* @function
|
|
102
104
|
* @param {string} textAlign ("left", "center", "right")
|
|
103
105
|
* @param {number} [scale]
|
|
104
106
|
* @returns {BitmapText} this object for chaining
|
|
@@ -106,51 +108,32 @@ export class BitmapText extends Renderable {
|
|
|
106
108
|
set(textAlign: string, scale?: number): BitmapText;
|
|
107
109
|
/**
|
|
108
110
|
* change the text to be displayed
|
|
109
|
-
* @name setText
|
|
110
|
-
* @memberof BitmapText.prototype
|
|
111
|
-
* @function
|
|
112
111
|
* @param {number|string|string[]} value a string, or an array of strings
|
|
113
112
|
* @returns {BitmapText} this object for chaining
|
|
114
113
|
*/
|
|
115
|
-
setText(value
|
|
114
|
+
setText(value?: number | string | string[]): BitmapText;
|
|
116
115
|
public set fillStyle(arg: Color);
|
|
117
116
|
/**
|
|
118
117
|
* defines the color used to tint the bitmap text
|
|
119
118
|
* @public
|
|
120
119
|
* @type {Color}
|
|
121
|
-
* @name fillStyle
|
|
122
120
|
* @see Renderable#tint
|
|
123
|
-
* @memberof BitmapText
|
|
124
121
|
*/
|
|
125
122
|
public get fillStyle(): Color;
|
|
126
123
|
/**
|
|
127
124
|
* change the font display size
|
|
128
|
-
* @name resize
|
|
129
|
-
* @memberof BitmapText.prototype
|
|
130
|
-
* @function
|
|
131
125
|
* @param {number} scale ratio
|
|
132
126
|
* @returns {BitmapText} this object for chaining
|
|
133
127
|
*/
|
|
134
128
|
resize(scale: number): BitmapText;
|
|
135
129
|
/**
|
|
136
130
|
* measure the given text size in pixels
|
|
137
|
-
* @name measureText
|
|
138
|
-
* @memberof BitmapText.prototype
|
|
139
|
-
* @function
|
|
140
131
|
* @param {string} [text]
|
|
141
|
-
* @param {Rect} [ret] a object in which to store the text metrics
|
|
142
132
|
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
143
133
|
*/
|
|
144
|
-
measureText(text?: string
|
|
145
|
-
/**
|
|
146
|
-
* @ignore
|
|
147
|
-
*/
|
|
148
|
-
update(): boolean;
|
|
134
|
+
measureText(text?: string): TextMetrics;
|
|
149
135
|
/**
|
|
150
136
|
* draw the bitmap font
|
|
151
|
-
* @name draw
|
|
152
|
-
* @memberof BitmapText.prototype
|
|
153
|
-
* @function
|
|
154
137
|
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
155
138
|
* @param {string} [text]
|
|
156
139
|
* @param {number} [x]
|
|
@@ -247,7 +230,7 @@ export class Body {
|
|
|
247
230
|
* @see collision.types
|
|
248
231
|
* @example
|
|
249
232
|
* // set the body collision type
|
|
250
|
-
*
|
|
233
|
+
* body.collisionType = me.collision.types.PLAYER_OBJECT;
|
|
251
234
|
*/
|
|
252
235
|
public collisionType: number;
|
|
253
236
|
vel: Vector2d;
|
|
@@ -384,17 +367,17 @@ export class Body {
|
|
|
384
367
|
*/
|
|
385
368
|
removeShapeAt(index: number): number;
|
|
386
369
|
/**
|
|
387
|
-
* By default all
|
|
370
|
+
* By default all physic bodies are able to collide with all other bodies, <br>
|
|
388
371
|
* but it's also possible to specify 'collision filters' to provide a finer <br>
|
|
389
|
-
* control over which
|
|
372
|
+
* control over which body can collide with each other.
|
|
390
373
|
* @see collision.types
|
|
391
374
|
* @param {number} [bitmask = collision.types.ALL_OBJECT] the collision mask
|
|
392
375
|
* @example
|
|
393
376
|
* // filter collision detection with collision shapes, enemies and collectables
|
|
394
|
-
*
|
|
377
|
+
* body.setCollisionMask(me.collision.types.WORLD_SHAPE | me.collision.types.ENEMY_OBJECT | me.collision.types.COLLECTABLE_OBJECT);
|
|
395
378
|
* ...
|
|
396
379
|
* // disable collision detection with all other objects
|
|
397
|
-
*
|
|
380
|
+
* body.setCollisionMask(me.collision.types.NO_OBJECT);
|
|
398
381
|
*/
|
|
399
382
|
setCollisionMask(bitmask?: number): void;
|
|
400
383
|
/**
|
|
@@ -403,7 +386,7 @@ export class Body {
|
|
|
403
386
|
* @param {number} type the collision type
|
|
404
387
|
* @example
|
|
405
388
|
* // set the body collision type
|
|
406
|
-
*
|
|
389
|
+
* body.collisionType = me.collision.types.PLAYER_OBJECT;
|
|
407
390
|
*/
|
|
408
391
|
setCollisionType(type: number): void;
|
|
409
392
|
/**
|
|
@@ -472,7 +455,7 @@ export class Body {
|
|
|
472
455
|
* Updates the parent's position as well as computes the new body's velocity based
|
|
473
456
|
* on the values of force/friction/gravity. Velocity chages are proportional to the
|
|
474
457
|
* me.timer.tick value (which can be used to scale velocities). The approach to moving the
|
|
475
|
-
* parent
|
|
458
|
+
* parent renderable is to compute new values of the Body.vel property then add them to
|
|
476
459
|
* the parent.pos value thus changing the postion the amount of Body.vel each time the
|
|
477
460
|
* update call is made. <br>
|
|
478
461
|
* Updates to Body.vel are bounded by maxVel (which defaults to viewport size if not set) <br>
|
|
@@ -949,7 +932,7 @@ export class Camera2d extends Renderable {
|
|
|
949
932
|
*/
|
|
950
933
|
moveTo(x: number, y: number): void;
|
|
951
934
|
/** @ignore */
|
|
952
|
-
updateTarget():
|
|
935
|
+
updateTarget(): void;
|
|
953
936
|
/** @ignore */
|
|
954
937
|
update(dt: any): boolean;
|
|
955
938
|
/**
|
|
@@ -1096,11 +1079,21 @@ export class CanvasRenderer extends Renderer {
|
|
|
1096
1079
|
*/
|
|
1097
1080
|
resetTransform(): void;
|
|
1098
1081
|
/**
|
|
1099
|
-
*
|
|
1082
|
+
* set a blend mode for the given context. <br>
|
|
1083
|
+
* Supported blend mode between Canvas and WebGL remderer : <br>
|
|
1084
|
+
* - "normal" : this is the default mode and draws new content on top of the existing content <br>
|
|
1085
|
+
* <img src="images/normal-blendmode.png" width="510"/> <br>
|
|
1086
|
+
* - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
|
|
1087
|
+
* <img src="images/multiply-blendmode.png" width="510"/> <br>
|
|
1088
|
+
* - "lighter" : where both content overlap the color is determined by adding color values. <br>
|
|
1089
|
+
* <img src="images/lighter-blendmode.png" width="510"/> <br>
|
|
1090
|
+
* - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
|
|
1091
|
+
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
1100
1092
|
* @name setBlendMode
|
|
1093
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
1101
1094
|
* @memberof CanvasRenderer.prototype
|
|
1102
1095
|
* @function
|
|
1103
|
-
* @param {string} [mode="normal"] blend mode : "normal", "multiply"
|
|
1096
|
+
* @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter, "screen"
|
|
1104
1097
|
* @param {CanvasRenderingContext2D} [context]
|
|
1105
1098
|
*/
|
|
1106
1099
|
setBlendMode(mode?: string, context?: CanvasRenderingContext2D): void;
|
|
@@ -5255,6 +5248,17 @@ export class Renderable extends Rect {
|
|
|
5255
5248
|
* this.tint.setColor(255, 255, 255);
|
|
5256
5249
|
*/
|
|
5257
5250
|
public tint: Color;
|
|
5251
|
+
/**
|
|
5252
|
+
* the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)
|
|
5253
|
+
* @public
|
|
5254
|
+
* @type {string}
|
|
5255
|
+
* @name blendMode
|
|
5256
|
+
* @default "normal"
|
|
5257
|
+
* @see CanvasRenderer#setBlendMode
|
|
5258
|
+
* @see WebGLRenderer#setBlendMode
|
|
5259
|
+
* @memberof Renderable#
|
|
5260
|
+
*/
|
|
5261
|
+
public blendMode: string;
|
|
5258
5262
|
/**
|
|
5259
5263
|
* The name of the renderable
|
|
5260
5264
|
* @public
|
|
@@ -6913,6 +6917,7 @@ export class Text extends Renderable {
|
|
|
6913
6917
|
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
6914
6918
|
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
6915
6919
|
* @param {boolean} [settings.offScreenCanvas=false] whether to draw the font to an individual "cache" texture first
|
|
6920
|
+
* @param {number} [settings.wordWrapWidth] the maximum length in CSS pixel for a single segment of text
|
|
6916
6921
|
* @param {(string|string[])} [settings.text=""] a string, or an array of strings
|
|
6917
6922
|
* @example
|
|
6918
6923
|
* var font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
|
|
@@ -6928,6 +6933,7 @@ export class Text extends Renderable {
|
|
|
6928
6933
|
lineHeight?: number;
|
|
6929
6934
|
anchorPoint?: Vector2d;
|
|
6930
6935
|
offScreenCanvas?: boolean;
|
|
6936
|
+
wordWrapWidth?: number;
|
|
6931
6937
|
text?: (string | string[]);
|
|
6932
6938
|
});
|
|
6933
6939
|
/** @ignore */
|
|
@@ -6939,7 +6945,6 @@ export class Text extends Renderable {
|
|
|
6939
6945
|
* @public
|
|
6940
6946
|
* @type {number}
|
|
6941
6947
|
* @default 1
|
|
6942
|
-
* @name Text#lineWidth
|
|
6943
6948
|
*/
|
|
6944
6949
|
public lineWidth: number;
|
|
6945
6950
|
/**
|
|
@@ -6948,7 +6953,6 @@ export class Text extends Renderable {
|
|
|
6948
6953
|
* @public
|
|
6949
6954
|
* @type {string}
|
|
6950
6955
|
* @default "left"
|
|
6951
|
-
* @name Text#textAlign
|
|
6952
6956
|
*/
|
|
6953
6957
|
public textAlign: string;
|
|
6954
6958
|
/**
|
|
@@ -6957,7 +6961,6 @@ export class Text extends Renderable {
|
|
|
6957
6961
|
* @public
|
|
6958
6962
|
* @type {string}
|
|
6959
6963
|
* @default "top"
|
|
6960
|
-
* @name Text#textBaseline
|
|
6961
6964
|
*/
|
|
6962
6965
|
public textBaseline: string;
|
|
6963
6966
|
/**
|
|
@@ -6966,7 +6969,6 @@ export class Text extends Renderable {
|
|
|
6966
6969
|
* @public
|
|
6967
6970
|
* @type {number}
|
|
6968
6971
|
* @default 1.0
|
|
6969
|
-
* @name Text#lineHeight
|
|
6970
6972
|
*/
|
|
6971
6973
|
public lineHeight: number;
|
|
6972
6974
|
/**
|
|
@@ -6976,9 +6978,16 @@ export class Text extends Renderable {
|
|
|
6976
6978
|
* @public
|
|
6977
6979
|
* @type {boolean}
|
|
6978
6980
|
* @default false
|
|
6979
|
-
* @name Text#offScreenCanvas
|
|
6980
6981
|
*/
|
|
6981
6982
|
public offScreenCanvas: boolean;
|
|
6983
|
+
/**
|
|
6984
|
+
* the maximum length in CSS pixel for a single segment of text.
|
|
6985
|
+
* (use -1 to disable word wrapping)
|
|
6986
|
+
* @public
|
|
6987
|
+
* @type {number}
|
|
6988
|
+
* @default -1
|
|
6989
|
+
*/
|
|
6990
|
+
public wordWrapWidth: number;
|
|
6982
6991
|
/**
|
|
6983
6992
|
* the text to be displayed
|
|
6984
6993
|
* @private
|
|
@@ -6988,38 +6997,28 @@ export class Text extends Renderable {
|
|
|
6988
6997
|
* the font size (in px)
|
|
6989
6998
|
* @public
|
|
6990
6999
|
* @type {number}
|
|
6991
|
-
* @name fontSize
|
|
6992
7000
|
* @default 10
|
|
6993
|
-
* @memberof Text
|
|
6994
7001
|
*/
|
|
6995
7002
|
public fontSize: number;
|
|
6996
7003
|
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
6997
7004
|
context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
7005
|
+
metrics: TextMetrics;
|
|
6998
7006
|
/** @ignore */
|
|
6999
7007
|
onDeactivateEvent(): void;
|
|
7000
7008
|
glTextureUnit: any;
|
|
7001
7009
|
/**
|
|
7002
7010
|
* make the font bold
|
|
7003
|
-
* @name bold
|
|
7004
|
-
* @memberof Text.prototype
|
|
7005
|
-
* @function
|
|
7006
7011
|
* @returns {Text} this object for chaining
|
|
7007
7012
|
*/
|
|
7008
7013
|
bold(): Text;
|
|
7009
7014
|
font: any;
|
|
7010
7015
|
/**
|
|
7011
7016
|
* make the font italic
|
|
7012
|
-
* @name italic
|
|
7013
|
-
* @memberof Text.prototype
|
|
7014
|
-
* @function
|
|
7015
7017
|
* @returns {Text} this object for chaining
|
|
7016
7018
|
*/
|
|
7017
7019
|
italic(): Text;
|
|
7018
7020
|
/**
|
|
7019
7021
|
* set the font family and size
|
|
7020
|
-
* @name setFont
|
|
7021
|
-
* @memberof Text.prototype
|
|
7022
|
-
* @function
|
|
7023
7022
|
* @param {string} font a CSS font name
|
|
7024
7023
|
* @param {number|string} [size=10] size in px, or size + suffix (px, em, pt)
|
|
7025
7024
|
* @returns {Text} this object for chaining
|
|
@@ -7030,33 +7029,19 @@ export class Text extends Renderable {
|
|
|
7030
7029
|
setFont(font: string, size?: number | string): Text;
|
|
7031
7030
|
/**
|
|
7032
7031
|
* change the text to be displayed
|
|
7033
|
-
* @name setText
|
|
7034
|
-
* @memberof Text.prototype
|
|
7035
|
-
* @function
|
|
7036
7032
|
* @param {number|string|string[]} value a string, or an array of strings
|
|
7037
7033
|
* @returns {Text} this object for chaining
|
|
7038
7034
|
*/
|
|
7039
7035
|
setText(value?: number | string | string[]): Text;
|
|
7040
7036
|
/**
|
|
7041
7037
|
* measure the given text size in pixels
|
|
7042
|
-
* @name measureText
|
|
7043
|
-
* @memberof Text.prototype
|
|
7044
|
-
* @function
|
|
7045
7038
|
* @param {CanvasRenderer|WebGLRenderer} [renderer] reference to the active renderer
|
|
7046
7039
|
* @param {string} [text] the text to be measured
|
|
7047
|
-
* @
|
|
7048
|
-
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
7049
|
-
*/
|
|
7050
|
-
measureText(renderer?: CanvasRenderer | WebGLRenderer, text?: string, ret?: Rect | Bounds): TextMetrics;
|
|
7051
|
-
/**
|
|
7052
|
-
* @ignore
|
|
7040
|
+
* @returns {TextMetrics} a TextMetrics object defining the dimensions of the given piece of text
|
|
7053
7041
|
*/
|
|
7054
|
-
|
|
7042
|
+
measureText(renderer$1?: CanvasRenderer | WebGLRenderer, text?: string): TextMetrics;
|
|
7055
7043
|
/**
|
|
7056
7044
|
* draw a text at the specified coord
|
|
7057
|
-
* @name draw
|
|
7058
|
-
* @memberof Text.prototype
|
|
7059
|
-
* @function
|
|
7060
7045
|
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
7061
7046
|
* @param {string} [text]
|
|
7062
7047
|
* @param {number} [x]
|
|
@@ -7068,9 +7053,6 @@ export class Text extends Renderable {
|
|
|
7068
7053
|
* draw a stroke text at the specified coord, as defined <br>
|
|
7069
7054
|
* by the `lineWidth` and `fillStroke` properties. <br>
|
|
7070
7055
|
* Note : using drawStroke is not recommended for performance reasons
|
|
7071
|
-
* @name drawStroke
|
|
7072
|
-
* @memberof Text.prototype
|
|
7073
|
-
* @function
|
|
7074
7056
|
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
7075
7057
|
* @param {string} text
|
|
7076
7058
|
* @param {number} x
|
|
@@ -7080,7 +7062,7 @@ export class Text extends Renderable {
|
|
|
7080
7062
|
/**
|
|
7081
7063
|
* @ignore
|
|
7082
7064
|
*/
|
|
7083
|
-
_drawFont(context: any, text: any, x: any, y: any, stroke?: boolean):
|
|
7065
|
+
_drawFont(context: any, text: any, x: any, y: any, stroke?: boolean): TextMetrics;
|
|
7084
7066
|
/**
|
|
7085
7067
|
* Destroy function
|
|
7086
7068
|
* @ignore
|
|
@@ -8634,6 +8616,10 @@ export class WebGLRenderer extends Renderer {
|
|
|
8634
8616
|
* @ignore
|
|
8635
8617
|
*/
|
|
8636
8618
|
_scissorStack: any[];
|
|
8619
|
+
/**
|
|
8620
|
+
* @ignore
|
|
8621
|
+
*/
|
|
8622
|
+
_blendStack: any[];
|
|
8637
8623
|
/**
|
|
8638
8624
|
* @ignore
|
|
8639
8625
|
*/
|
|
@@ -8799,14 +8785,25 @@ export class WebGLRenderer extends Renderer {
|
|
|
8799
8785
|
*/
|
|
8800
8786
|
getContext(): WebGLRenderingContext;
|
|
8801
8787
|
/**
|
|
8802
|
-
* set a blend mode for the given context
|
|
8788
|
+
* set a blend mode for the given context. <br>
|
|
8789
|
+
* Supported blend mode between Canvas and WebGL remderer : <br>
|
|
8790
|
+
* - "normal" : this is the default mode and draws new content on top of the existing content <br>
|
|
8791
|
+
* <img src="images/normal-blendmode.png" width="510"/> <br>
|
|
8792
|
+
* - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
|
|
8793
|
+
* <img src="images/multiply-blendmode.png" width="510"/> <br>
|
|
8794
|
+
* - "lighter" : where both content overlap the color is determined by adding color values. <br>
|
|
8795
|
+
* <img src="images/lighter-blendmode.png" width="510"/> <br>
|
|
8796
|
+
* - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
|
|
8797
|
+
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
8803
8798
|
* @name setBlendMode
|
|
8799
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
8804
8800
|
* @memberof WebGLRenderer.prototype
|
|
8805
8801
|
* @function
|
|
8806
|
-
* @param {string} [mode="normal"] blend mode : "normal", "multiply"
|
|
8802
|
+
* @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "screen"
|
|
8807
8803
|
* @param {WebGLRenderingContext} [gl]
|
|
8808
8804
|
*/
|
|
8809
8805
|
setBlendMode(mode?: string, gl?: WebGLRenderingContext): void;
|
|
8806
|
+
currentBlendMode: any;
|
|
8810
8807
|
/**
|
|
8811
8808
|
* return a reference to the font 2d Context
|
|
8812
8809
|
* @ignore
|
|
@@ -10168,184 +10165,16 @@ export var plugin: any;
|
|
|
10168
10165
|
* @namespace plugins
|
|
10169
10166
|
*/
|
|
10170
10167
|
export var plugins: {};
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
* // implement CherryEntity
|
|
10182
|
-
* class CherryEntity extends Spritesheet {
|
|
10183
|
-
* onResetEvent() {
|
|
10184
|
-
* // reset object mutable properties
|
|
10185
|
-
* this.lifeBar = 100;
|
|
10186
|
-
* }
|
|
10187
|
-
* };
|
|
10188
|
-
* // add our users defined entities in the object pool and enable object recycling
|
|
10189
|
-
* me.pool.register("cherryentity", CherryEntity, true);
|
|
10190
|
-
*/
|
|
10191
|
-
function register(className: string, classObj: any, recycling?: boolean): void;
|
|
10192
|
-
/**
|
|
10193
|
-
* register an object to the pool. <br>
|
|
10194
|
-
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
10195
|
-
* (Note: for an object to be poolable, it must implements a `onResetEvent` method)
|
|
10196
|
-
* @function pool.register
|
|
10197
|
-
* @param {string} className as defined in the Name field of the Object Properties (in Tiled)
|
|
10198
|
-
* @param {object} classObj corresponding Class to be instantiated
|
|
10199
|
-
* @param {boolean} [recycling=false] enables object recycling for the specified class
|
|
10200
|
-
* @example
|
|
10201
|
-
* // implement CherryEntity
|
|
10202
|
-
* class CherryEntity extends Spritesheet {
|
|
10203
|
-
* onResetEvent() {
|
|
10204
|
-
* // reset object mutable properties
|
|
10205
|
-
* this.lifeBar = 100;
|
|
10206
|
-
* }
|
|
10207
|
-
* };
|
|
10208
|
-
* // add our users defined entities in the object pool and enable object recycling
|
|
10209
|
-
* me.pool.register("cherryentity", CherryEntity, true);
|
|
10210
|
-
*/
|
|
10211
|
-
function register(className: string, classObj: any, recycling?: boolean): void;
|
|
10212
|
-
/**
|
|
10213
|
-
* Pull a new instance of the requested object (if added into the object pool)
|
|
10214
|
-
* @function pool.pull
|
|
10215
|
-
* @param {string} name as used in {@link pool.register}
|
|
10216
|
-
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
10217
|
-
* @returns {object} the instance of the requested object
|
|
10218
|
-
* @example
|
|
10219
|
-
* me.pool.register("bullet", BulletEntity, true);
|
|
10220
|
-
* me.pool.register("enemy", EnemyEntity, true);
|
|
10221
|
-
* // ...
|
|
10222
|
-
* // when we need to manually create a new bullet:
|
|
10223
|
-
* var bullet = me.pool.pull("bullet", x, y, direction);
|
|
10224
|
-
* // ...
|
|
10225
|
-
* // params aren't a fixed number
|
|
10226
|
-
* // when we need new enemy we can add more params, that the object construct requires:
|
|
10227
|
-
* var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
|
|
10228
|
-
* // ...
|
|
10229
|
-
* // when we want to destroy existing object, the remove
|
|
10230
|
-
* // function will ensure the object can then be reallocated later
|
|
10231
|
-
* me.game.world.removeChild(enemy);
|
|
10232
|
-
* me.game.world.removeChild(bullet);
|
|
10233
|
-
*/
|
|
10234
|
-
function pull(name: string, ...args: any[]): any;
|
|
10235
|
-
/**
|
|
10236
|
-
* Pull a new instance of the requested object (if added into the object pool)
|
|
10237
|
-
* @function pool.pull
|
|
10238
|
-
* @param {string} name as used in {@link pool.register}
|
|
10239
|
-
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
10240
|
-
* @returns {object} the instance of the requested object
|
|
10241
|
-
* @example
|
|
10242
|
-
* me.pool.register("bullet", BulletEntity, true);
|
|
10243
|
-
* me.pool.register("enemy", EnemyEntity, true);
|
|
10244
|
-
* // ...
|
|
10245
|
-
* // when we need to manually create a new bullet:
|
|
10246
|
-
* var bullet = me.pool.pull("bullet", x, y, direction);
|
|
10247
|
-
* // ...
|
|
10248
|
-
* // params aren't a fixed number
|
|
10249
|
-
* // when we need new enemy we can add more params, that the object construct requires:
|
|
10250
|
-
* var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
|
|
10251
|
-
* // ...
|
|
10252
|
-
* // when we want to destroy existing object, the remove
|
|
10253
|
-
* // function will ensure the object can then be reallocated later
|
|
10254
|
-
* me.game.world.removeChild(enemy);
|
|
10255
|
-
* me.game.world.removeChild(bullet);
|
|
10256
|
-
*/
|
|
10257
|
-
function pull(name: string, ...args: any[]): any;
|
|
10258
|
-
/**
|
|
10259
|
-
* purge the object pool from any inactive object <br>
|
|
10260
|
-
* Object pooling must be enabled for this function to work<br>
|
|
10261
|
-
* note: this will trigger the garbage collector
|
|
10262
|
-
* @function pool.purge
|
|
10263
|
-
*/
|
|
10264
|
-
function purge(): void;
|
|
10265
|
-
/**
|
|
10266
|
-
* purge the object pool from any inactive object <br>
|
|
10267
|
-
* Object pooling must be enabled for this function to work<br>
|
|
10268
|
-
* note: this will trigger the garbage collector
|
|
10269
|
-
* @function pool.purge
|
|
10270
|
-
*/
|
|
10271
|
-
function purge(): void;
|
|
10272
|
-
/**
|
|
10273
|
-
* Push back an object instance into the object pool <br>
|
|
10274
|
-
* Object pooling for the object class must be enabled,
|
|
10275
|
-
* and object must have been instantiated using {@link pool#pull},
|
|
10276
|
-
* otherwise this function won't work
|
|
10277
|
-
* @function pool.push
|
|
10278
|
-
* @throws will throw an error if the object cannot be recycled
|
|
10279
|
-
* @param {object} obj instance to be recycled
|
|
10280
|
-
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
10281
|
-
* @returns {boolean} true if the object was successfully recycled in the object pool
|
|
10282
|
-
*/
|
|
10283
|
-
function push(obj: any, throwOnError?: boolean): boolean;
|
|
10284
|
-
/**
|
|
10285
|
-
* Push back an object instance into the object pool <br>
|
|
10286
|
-
* Object pooling for the object class must be enabled,
|
|
10287
|
-
* and object must have been instantiated using {@link pool#pull},
|
|
10288
|
-
* otherwise this function won't work
|
|
10289
|
-
* @function pool.push
|
|
10290
|
-
* @throws will throw an error if the object cannot be recycled
|
|
10291
|
-
* @param {object} obj instance to be recycled
|
|
10292
|
-
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
10293
|
-
* @returns {boolean} true if the object was successfully recycled in the object pool
|
|
10294
|
-
*/
|
|
10295
|
-
function push(obj: any, throwOnError?: boolean): boolean;
|
|
10296
|
-
/**
|
|
10297
|
-
* Check if an object with the provided name is registered
|
|
10298
|
-
* @function pool.exists
|
|
10299
|
-
* @param {string} name of the registered object class
|
|
10300
|
-
* @returns {boolean} true if the classname is registered
|
|
10301
|
-
*/
|
|
10302
|
-
function exists(name: string): boolean;
|
|
10303
|
-
/**
|
|
10304
|
-
* Check if an object with the provided name is registered
|
|
10305
|
-
* @function pool.exists
|
|
10306
|
-
* @param {string} name of the registered object class
|
|
10307
|
-
* @returns {boolean} true if the classname is registered
|
|
10308
|
-
*/
|
|
10309
|
-
function exists(name: string): boolean;
|
|
10310
|
-
/**
|
|
10311
|
-
* Check if an object is poolable
|
|
10312
|
-
* (was properly registered with the recycling feature enable)
|
|
10313
|
-
* @function pool.poolable
|
|
10314
|
-
* @see pool.register
|
|
10315
|
-
* @param {object} obj object to be checked
|
|
10316
|
-
* @returns {boolean} true if the object is poolable
|
|
10317
|
-
* @example
|
|
10318
|
-
* if (!me.pool.poolable(myCherryEntity)) {
|
|
10319
|
-
* // object was not properly registered
|
|
10320
|
-
* }
|
|
10321
|
-
*/
|
|
10322
|
-
function poolable(obj: any): boolean;
|
|
10323
|
-
/**
|
|
10324
|
-
* Check if an object is poolable
|
|
10325
|
-
* (was properly registered with the recycling feature enable)
|
|
10326
|
-
* @function pool.poolable
|
|
10327
|
-
* @see pool.register
|
|
10328
|
-
* @param {object} obj object to be checked
|
|
10329
|
-
* @returns {boolean} true if the object is poolable
|
|
10330
|
-
* @example
|
|
10331
|
-
* if (!me.pool.poolable(myCherryEntity)) {
|
|
10332
|
-
* // object was not properly registered
|
|
10333
|
-
* }
|
|
10334
|
-
*/
|
|
10335
|
-
function poolable(obj: any): boolean;
|
|
10336
|
-
/**
|
|
10337
|
-
* returns the amount of object instance currently in the pool
|
|
10338
|
-
* @function pool.getInstanceCount
|
|
10339
|
-
* @returns {number} amount of object instance
|
|
10340
|
-
*/
|
|
10341
|
-
function getInstanceCount(): number;
|
|
10342
|
-
/**
|
|
10343
|
-
* returns the amount of object instance currently in the pool
|
|
10344
|
-
* @function pool.getInstanceCount
|
|
10345
|
-
* @returns {number} amount of object instance
|
|
10346
|
-
*/
|
|
10347
|
-
function getInstanceCount(): number;
|
|
10348
|
-
}
|
|
10168
|
+
declare var pooling: Readonly<{
|
|
10169
|
+
__proto__: any;
|
|
10170
|
+
register: typeof register;
|
|
10171
|
+
pull: typeof pull;
|
|
10172
|
+
purge: typeof purge;
|
|
10173
|
+
push: typeof push;
|
|
10174
|
+
exists: typeof exists;
|
|
10175
|
+
poolable: typeof poolable;
|
|
10176
|
+
getInstanceCount: typeof getInstanceCount;
|
|
10177
|
+
}>;
|
|
10349
10178
|
export namespace save {
|
|
10350
10179
|
/**
|
|
10351
10180
|
* Add new keys to localStorage and set them to the given default values if they do not exist
|
|
@@ -10416,7 +10245,7 @@ export namespace state {
|
|
|
10416
10245
|
const DEFAULT: number;
|
|
10417
10246
|
const USER: number;
|
|
10418
10247
|
/**
|
|
10419
|
-
* Stop the current
|
|
10248
|
+
* Stop the current stage.
|
|
10420
10249
|
* @name stop
|
|
10421
10250
|
* @memberof state
|
|
10422
10251
|
* @public
|
|
@@ -10425,7 +10254,7 @@ export namespace state {
|
|
|
10425
10254
|
*/
|
|
10426
10255
|
function stop(pauseTrack?: boolean): void;
|
|
10427
10256
|
/**
|
|
10428
|
-
* Stop the current
|
|
10257
|
+
* Stop the current stage.
|
|
10429
10258
|
* @name stop
|
|
10430
10259
|
* @memberof state
|
|
10431
10260
|
* @public
|
|
@@ -10434,7 +10263,7 @@ export namespace state {
|
|
|
10434
10263
|
*/
|
|
10435
10264
|
function stop(pauseTrack?: boolean): void;
|
|
10436
10265
|
/**
|
|
10437
|
-
* pause the current
|
|
10266
|
+
* pause the current stage
|
|
10438
10267
|
* @name pause
|
|
10439
10268
|
* @memberof state
|
|
10440
10269
|
* @public
|
|
@@ -10443,7 +10272,7 @@ export namespace state {
|
|
|
10443
10272
|
*/
|
|
10444
10273
|
function pause(music?: boolean): void;
|
|
10445
10274
|
/**
|
|
10446
|
-
* pause the current
|
|
10275
|
+
* pause the current stage
|
|
10447
10276
|
* @name pause
|
|
10448
10277
|
* @memberof state
|
|
10449
10278
|
* @public
|
|
@@ -10452,7 +10281,7 @@ export namespace state {
|
|
|
10452
10281
|
*/
|
|
10453
10282
|
function pause(music?: boolean): void;
|
|
10454
10283
|
/**
|
|
10455
|
-
* Restart the
|
|
10284
|
+
* Restart the current stage from a full stop.
|
|
10456
10285
|
* @name restart
|
|
10457
10286
|
* @memberof state
|
|
10458
10287
|
* @public
|
|
@@ -10461,7 +10290,7 @@ export namespace state {
|
|
|
10461
10290
|
*/
|
|
10462
10291
|
function restart(music?: boolean): void;
|
|
10463
10292
|
/**
|
|
10464
|
-
* Restart the
|
|
10293
|
+
* Restart the current stage from a full stop.
|
|
10465
10294
|
* @name restart
|
|
10466
10295
|
* @memberof state
|
|
10467
10296
|
* @public
|
|
@@ -10470,7 +10299,7 @@ export namespace state {
|
|
|
10470
10299
|
*/
|
|
10471
10300
|
function restart(music?: boolean): void;
|
|
10472
10301
|
/**
|
|
10473
|
-
* resume the
|
|
10302
|
+
* resume the current stage
|
|
10474
10303
|
* @name resume
|
|
10475
10304
|
* @memberof state
|
|
10476
10305
|
* @public
|
|
@@ -10479,7 +10308,7 @@ export namespace state {
|
|
|
10479
10308
|
*/
|
|
10480
10309
|
function resume(music?: boolean): void;
|
|
10481
10310
|
/**
|
|
10482
|
-
* resume the
|
|
10311
|
+
* resume the current stage
|
|
10483
10312
|
* @name resume
|
|
10484
10313
|
* @memberof state
|
|
10485
10314
|
* @public
|
|
@@ -10618,7 +10447,7 @@ export namespace state {
|
|
|
10618
10447
|
*/
|
|
10619
10448
|
function set(state: number, stage: Stage, start?: boolean): void;
|
|
10620
10449
|
/**
|
|
10621
|
-
* return a reference to the current
|
|
10450
|
+
* return a reference to the current stage<br>
|
|
10622
10451
|
* useful to call a object specific method
|
|
10623
10452
|
* @name current
|
|
10624
10453
|
* @memberof state
|
|
@@ -10628,7 +10457,7 @@ export namespace state {
|
|
|
10628
10457
|
*/
|
|
10629
10458
|
function current(): Stage;
|
|
10630
10459
|
/**
|
|
10631
|
-
* return a reference to the current
|
|
10460
|
+
* return a reference to the current stage<br>
|
|
10632
10461
|
* useful to call a object specific method
|
|
10633
10462
|
* @name current
|
|
10634
10463
|
* @memberof state
|
|
@@ -10946,6 +10775,51 @@ export var video: Readonly<{
|
|
|
10946
10775
|
* @param {string} version the version since when the lass,function or property is deprecated
|
|
10947
10776
|
*/
|
|
10948
10777
|
export function warning(deprecated: string, replacement: string, version: string): void;
|
|
10778
|
+
/**
|
|
10779
|
+
* @classdesc
|
|
10780
|
+
* a Text Metrics object that contains helper for text manipulation
|
|
10781
|
+
* @augments Bounds
|
|
10782
|
+
*/
|
|
10783
|
+
declare class TextMetrics extends Bounds {
|
|
10784
|
+
/**
|
|
10785
|
+
* @param {Text|BitmapText} ancestor the parent object that contains this TextMetrics object
|
|
10786
|
+
*/
|
|
10787
|
+
constructor(ancestor: Text | BitmapText);
|
|
10788
|
+
/**
|
|
10789
|
+
* a reference to the parent object that contains this TextMetrics object
|
|
10790
|
+
* @public
|
|
10791
|
+
* @type {Renderable}
|
|
10792
|
+
* @default undefined
|
|
10793
|
+
*/
|
|
10794
|
+
public ancestor: Renderable;
|
|
10795
|
+
/**
|
|
10796
|
+
* Returns the height of a segment of inline text in CSS pixels.
|
|
10797
|
+
* @returns {number} the height of a segment of inline text in CSS pixels.
|
|
10798
|
+
*/
|
|
10799
|
+
lineHeight(): number;
|
|
10800
|
+
/**
|
|
10801
|
+
* Returns the width of the given segment of inline text in CSS pixels.
|
|
10802
|
+
* @param {string} text the text to be measured
|
|
10803
|
+
* @param {CanvasRenderingContext2D} [context] reference to an active 2d context for canvas rendering
|
|
10804
|
+
* @returns {number} the width of the given segment of inline text in CSS pixels.
|
|
10805
|
+
*/
|
|
10806
|
+
lineWidth(text: string, context?: CanvasRenderingContext2D): number;
|
|
10807
|
+
/**
|
|
10808
|
+
* measure the given text size in CSS pixels
|
|
10809
|
+
* @param {string} text the text to be measured
|
|
10810
|
+
* @param {CanvasRenderingContext2D} [context] reference to an active 2d context for canvas rendering
|
|
10811
|
+
* @returns {TextMetrics} this
|
|
10812
|
+
*/
|
|
10813
|
+
measureText(text: string, context?: CanvasRenderingContext2D): TextMetrics;
|
|
10814
|
+
/**
|
|
10815
|
+
* wrap the given text based on the given width
|
|
10816
|
+
* @param {string|string[]} text the text to be wrapped
|
|
10817
|
+
* @param {number} width maximum width of one segment of text in css pixel
|
|
10818
|
+
* @param {CanvasRenderingContext2D} [context] reference to an active 2d context for canvas rendering
|
|
10819
|
+
* @returns {string[]} an array of string representing wrapped text
|
|
10820
|
+
*/
|
|
10821
|
+
wordWrap(text: string | string[], width: number, context?: CanvasRenderingContext2D): string[];
|
|
10822
|
+
}
|
|
10949
10823
|
/**
|
|
10950
10824
|
* @classdesc
|
|
10951
10825
|
* a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
|
|
@@ -12127,6 +12001,107 @@ declare function setGamepadDeadzone(value: number): void;
|
|
|
12127
12001
|
* @ignore
|
|
12128
12002
|
*/
|
|
12129
12003
|
declare function addMapping(id: any, mapping: any): void;
|
|
12004
|
+
/**
|
|
12005
|
+
* This object is used for object pooling - a technique that might speed up your game if used properly.<br>
|
|
12006
|
+
* If some of your classes will be instantiated and removed a lot at a time, it is a
|
|
12007
|
+
* good idea to add the class to this object pool. A separate pool for that class
|
|
12008
|
+
* will be created, which will reuse objects of the class. That way they won't be instantiated
|
|
12009
|
+
* each time you need a new one (slowing your game), but stored into that pool and taking one
|
|
12010
|
+
* already instantiated when you need it.<br><br>
|
|
12011
|
+
* This object is also used by the engine to instantiate objects defined in the map,
|
|
12012
|
+
* which means, that on level loading the engine will try to instantiate every object
|
|
12013
|
+
* found in the map, based on the user defined name in each Object Properties<br>
|
|
12014
|
+
* <img src="images/object_properties.png"/><br>
|
|
12015
|
+
* @namespace pool
|
|
12016
|
+
*/
|
|
12017
|
+
/**
|
|
12018
|
+
* register an object to the pool. <br>
|
|
12019
|
+
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
12020
|
+
* (Note: for an object to be poolable, it must implements a `onResetEvent` method)
|
|
12021
|
+
* @function pool.register
|
|
12022
|
+
* @param {string} className as defined in the Name field of the Object Properties (in Tiled)
|
|
12023
|
+
* @param {object} classObj corresponding Class to be instantiated
|
|
12024
|
+
* @param {boolean} [recycling=false] enables object recycling for the specified class
|
|
12025
|
+
* @example
|
|
12026
|
+
* // implement CherryEntity
|
|
12027
|
+
* class CherryEntity extends Spritesheet {
|
|
12028
|
+
* onResetEvent() {
|
|
12029
|
+
* // reset object mutable properties
|
|
12030
|
+
* this.lifeBar = 100;
|
|
12031
|
+
* }
|
|
12032
|
+
* };
|
|
12033
|
+
* // add our users defined entities in the object pool and enable object recycling
|
|
12034
|
+
* me.pool.register("cherryentity", CherryEntity, true);
|
|
12035
|
+
*/
|
|
12036
|
+
declare function register(className: string, classObj: object, recycling?: boolean): void;
|
|
12037
|
+
/**
|
|
12038
|
+
* Pull a new instance of the requested object (if added into the object pool)
|
|
12039
|
+
* @function pool.pull
|
|
12040
|
+
* @param {string} name as used in {@link pool.register}
|
|
12041
|
+
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
12042
|
+
* @returns {object} the instance of the requested object
|
|
12043
|
+
* @example
|
|
12044
|
+
* me.pool.register("bullet", BulletEntity, true);
|
|
12045
|
+
* me.pool.register("enemy", EnemyEntity, true);
|
|
12046
|
+
* // ...
|
|
12047
|
+
* // when we need to manually create a new bullet:
|
|
12048
|
+
* var bullet = me.pool.pull("bullet", x, y, direction);
|
|
12049
|
+
* // ...
|
|
12050
|
+
* // params aren't a fixed number
|
|
12051
|
+
* // when we need new enemy we can add more params, that the object construct requires:
|
|
12052
|
+
* var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
|
|
12053
|
+
* // ...
|
|
12054
|
+
* // when we want to destroy existing object, the remove
|
|
12055
|
+
* // function will ensure the object can then be reallocated later
|
|
12056
|
+
* me.game.world.removeChild(enemy);
|
|
12057
|
+
* me.game.world.removeChild(bullet);
|
|
12058
|
+
*/
|
|
12059
|
+
declare function pull(name: string, ...args: any[]): object;
|
|
12060
|
+
/**
|
|
12061
|
+
* purge the object pool from any inactive object <br>
|
|
12062
|
+
* Object pooling must be enabled for this function to work<br>
|
|
12063
|
+
* note: this will trigger the garbage collector
|
|
12064
|
+
* @function pool.purge
|
|
12065
|
+
*/
|
|
12066
|
+
declare function purge(): void;
|
|
12067
|
+
/**
|
|
12068
|
+
* Push back an object instance into the object pool <br>
|
|
12069
|
+
* Object pooling for the object class must be enabled,
|
|
12070
|
+
* and object must have been instantiated using {@link pool#pull},
|
|
12071
|
+
* otherwise this function won't work
|
|
12072
|
+
* @function pool.push
|
|
12073
|
+
* @throws will throw an error if the object cannot be recycled
|
|
12074
|
+
* @param {object} obj instance to be recycled
|
|
12075
|
+
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
12076
|
+
* @returns {boolean} true if the object was successfully recycled in the object pool
|
|
12077
|
+
*/
|
|
12078
|
+
declare function push(obj: object, throwOnError?: boolean): boolean;
|
|
12079
|
+
/**
|
|
12080
|
+
* Check if an object with the provided name is registered
|
|
12081
|
+
* @function pool.exists
|
|
12082
|
+
* @param {string} name of the registered object class
|
|
12083
|
+
* @returns {boolean} true if the classname is registered
|
|
12084
|
+
*/
|
|
12085
|
+
declare function exists(name: string): boolean;
|
|
12086
|
+
/**
|
|
12087
|
+
* Check if an object is poolable
|
|
12088
|
+
* (was properly registered with the recycling feature enable)
|
|
12089
|
+
* @function pool.poolable
|
|
12090
|
+
* @see pool.register
|
|
12091
|
+
* @param {object} obj object to be checked
|
|
12092
|
+
* @returns {boolean} true if the object is poolable
|
|
12093
|
+
* @example
|
|
12094
|
+
* if (!me.pool.poolable(myCherryEntity)) {
|
|
12095
|
+
* // object was not properly registered
|
|
12096
|
+
* }
|
|
12097
|
+
*/
|
|
12098
|
+
declare function poolable(obj: object): boolean;
|
|
12099
|
+
/**
|
|
12100
|
+
* returns the amount of object instance currently in the pool
|
|
12101
|
+
* @function pool.getInstanceCount
|
|
12102
|
+
* @returns {number} amount of object instance
|
|
12103
|
+
*/
|
|
12104
|
+
declare function getInstanceCount(): number;
|
|
12130
12105
|
declare var agentUtils: Readonly<{
|
|
12131
12106
|
__proto__: any;
|
|
12132
12107
|
prefixed: typeof prefixed;
|
|
@@ -12419,4 +12394,4 @@ declare function defer(func: Function, thisArg: object, ...args: any[]): number;
|
|
|
12419
12394
|
* @returns {Function} the function that will be throttled
|
|
12420
12395
|
*/
|
|
12421
12396
|
declare function throttle(fn: Function, delay: number, no_trailing: any): Function;
|
|
12422
|
-
export { Bounds$1 as Bounds, math as Math, device$1 as device, timer$1 as timer };
|
|
12397
|
+
export { Bounds$1 as Bounds, math as Math, device$1 as device, pooling as pool, timer$1 as timer };
|