melonjs 10.9.0 → 10.10.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/LICENSE.md +1 -1
- package/README.md +29 -23
- package/dist/melonjs.js +812 -485
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +413 -230
- package/dist/melonjs.module.js +751 -437
- package/package.json +13 -10
- package/src/game.js +2 -2
- package/src/geometries/ellipse.js +16 -16
- package/src/geometries/line.js +4 -4
- package/src/geometries/path2d.js +10 -10
- package/src/geometries/poly.js +23 -23
- package/src/geometries/rectangle.js +22 -22
- package/src/geometries/roundrect.js +6 -6
- package/src/index.js +7 -1
- package/src/lang/deprecated.js +7 -5
- package/src/level/tiled/TMXUtils.js +1 -1
- package/src/loader/loadingscreen.js +16 -5
- package/src/math/color.js +5 -4
- package/src/particles/emitter.js +11 -12
- package/src/renderable/GUI.js +5 -5
- package/src/renderable/container.js +26 -26
- package/src/renderable/imagelayer.js +2 -2
- package/src/renderable/light2d.js +115 -0
- package/src/renderable/renderable.js +21 -20
- package/src/renderable/sprite.js +13 -13
- package/src/state/stage.js +72 -2
- package/src/text/text.js +13 -17
- package/src/video/canvas/canvas_renderer.js +69 -51
- package/src/video/renderer.js +33 -26
- package/src/video/{texture.js → texture/atlas.js} +8 -8
- package/src/video/{texture_cache.js → texture/cache.js} +4 -4
- package/src/video/texture/canvas_texture.js +87 -0
- package/src/video/webgl/webgl_renderer.js +73 -55
|
@@ -32,7 +32,7 @@ class Rect extends Polygon {
|
|
|
32
32
|
/**
|
|
33
33
|
* set new value to the rectangle shape
|
|
34
34
|
* @name setShape
|
|
35
|
-
* @memberof Rect
|
|
35
|
+
* @memberof Rect
|
|
36
36
|
* @function
|
|
37
37
|
* @param {number} x position of the Rectangle
|
|
38
38
|
* @param {number} y position of the Rectangle
|
|
@@ -63,7 +63,7 @@ class Rect extends Polygon {
|
|
|
63
63
|
* @public
|
|
64
64
|
* @type {number}
|
|
65
65
|
* @name left
|
|
66
|
-
* @memberof Rect
|
|
66
|
+
* @memberof Rect
|
|
67
67
|
*/
|
|
68
68
|
get left() {
|
|
69
69
|
return this.pos.x;
|
|
@@ -74,7 +74,7 @@ class Rect extends Polygon {
|
|
|
74
74
|
* @public
|
|
75
75
|
* @type {number}
|
|
76
76
|
* @name right
|
|
77
|
-
* @memberof Rect
|
|
77
|
+
* @memberof Rect
|
|
78
78
|
*/
|
|
79
79
|
get right() {
|
|
80
80
|
var w = this.width;
|
|
@@ -86,7 +86,7 @@ class Rect extends Polygon {
|
|
|
86
86
|
* @public
|
|
87
87
|
* @type {number}
|
|
88
88
|
* @name top
|
|
89
|
-
* @memberof Rect
|
|
89
|
+
* @memberof Rect
|
|
90
90
|
*/
|
|
91
91
|
get top() {
|
|
92
92
|
return this.pos.y;
|
|
@@ -97,7 +97,7 @@ class Rect extends Polygon {
|
|
|
97
97
|
* @public
|
|
98
98
|
* @type {number}
|
|
99
99
|
* @name bottom
|
|
100
|
-
* @memberof Rect
|
|
100
|
+
* @memberof Rect
|
|
101
101
|
*/
|
|
102
102
|
get bottom() {
|
|
103
103
|
var h = this.height;
|
|
@@ -109,7 +109,7 @@ class Rect extends Polygon {
|
|
|
109
109
|
* @public
|
|
110
110
|
* @type {number}
|
|
111
111
|
* @name width
|
|
112
|
-
* @memberof Rect
|
|
112
|
+
* @memberof Rect
|
|
113
113
|
*/
|
|
114
114
|
get width() {
|
|
115
115
|
return this.points[2].x;
|
|
@@ -125,7 +125,7 @@ class Rect extends Polygon {
|
|
|
125
125
|
* @public
|
|
126
126
|
* @type {number}
|
|
127
127
|
* @name height
|
|
128
|
-
* @memberof Rect
|
|
128
|
+
* @memberof Rect
|
|
129
129
|
*/
|
|
130
130
|
get height() {
|
|
131
131
|
return this.points[2].y;
|
|
@@ -141,7 +141,7 @@ class Rect extends Polygon {
|
|
|
141
141
|
* @public
|
|
142
142
|
* @type {number}
|
|
143
143
|
* @name centerX
|
|
144
|
-
* @memberof Rect
|
|
144
|
+
* @memberof Rect
|
|
145
145
|
*/
|
|
146
146
|
get centerX() {
|
|
147
147
|
if (isFinite(this.width)) {
|
|
@@ -159,7 +159,7 @@ class Rect extends Polygon {
|
|
|
159
159
|
* @public
|
|
160
160
|
* @type {number}
|
|
161
161
|
* @name centerY
|
|
162
|
-
* @memberof Rect
|
|
162
|
+
* @memberof Rect
|
|
163
163
|
*/
|
|
164
164
|
get centerY() {
|
|
165
165
|
if (isFinite(this.height)) {
|
|
@@ -175,7 +175,7 @@ class Rect extends Polygon {
|
|
|
175
175
|
/**
|
|
176
176
|
* center the rectangle position around the given coordinates
|
|
177
177
|
* @name centerOn
|
|
178
|
-
* @memberof Rect
|
|
178
|
+
* @memberof Rect
|
|
179
179
|
* @function
|
|
180
180
|
* @param {number} x the x coordinate around which to center this rectangle
|
|
181
181
|
* @param {number} x the y coordinate around which to center this rectangle
|
|
@@ -190,7 +190,7 @@ class Rect extends Polygon {
|
|
|
190
190
|
/**
|
|
191
191
|
* resize the rectangle
|
|
192
192
|
* @name resize
|
|
193
|
-
* @memberof Rect
|
|
193
|
+
* @memberof Rect
|
|
194
194
|
* @function
|
|
195
195
|
* @param {number} w new width of the rectangle
|
|
196
196
|
* @param {number} h new height of the rectangle
|
|
@@ -205,7 +205,7 @@ class Rect extends Polygon {
|
|
|
205
205
|
/**
|
|
206
206
|
* scale the rectangle
|
|
207
207
|
* @name scale
|
|
208
|
-
* @memberof Rect
|
|
208
|
+
* @memberof Rect
|
|
209
209
|
* @function
|
|
210
210
|
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
211
211
|
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
@@ -220,7 +220,7 @@ class Rect extends Polygon {
|
|
|
220
220
|
/**
|
|
221
221
|
* clone this rectangle
|
|
222
222
|
* @name clone
|
|
223
|
-
* @memberof Rect
|
|
223
|
+
* @memberof Rect
|
|
224
224
|
* @function
|
|
225
225
|
* @returns {Rect} new rectangle
|
|
226
226
|
*/
|
|
@@ -231,7 +231,7 @@ class Rect extends Polygon {
|
|
|
231
231
|
/**
|
|
232
232
|
* copy the position and size of the given rectangle into this one
|
|
233
233
|
* @name copy
|
|
234
|
-
* @memberof Rect
|
|
234
|
+
* @memberof Rect
|
|
235
235
|
* @function
|
|
236
236
|
* @param {Rect} rect Source rectangle
|
|
237
237
|
* @returns {Rect} new rectangle
|
|
@@ -243,7 +243,7 @@ class Rect extends Polygon {
|
|
|
243
243
|
/**
|
|
244
244
|
* merge this rectangle with another one
|
|
245
245
|
* @name union
|
|
246
|
-
* @memberof Rect
|
|
246
|
+
* @memberof Rect
|
|
247
247
|
* @function
|
|
248
248
|
* @param {Rect} rect other rectangle to union with
|
|
249
249
|
* @returns {Rect} the union(ed) rectangle
|
|
@@ -265,7 +265,7 @@ class Rect extends Polygon {
|
|
|
265
265
|
/**
|
|
266
266
|
* check if this rectangle is intersecting with the specified one
|
|
267
267
|
* @name overlaps
|
|
268
|
-
* @memberof Rect
|
|
268
|
+
* @memberof Rect
|
|
269
269
|
* @function
|
|
270
270
|
* @param {Rect} rect
|
|
271
271
|
* @returns {boolean} true if overlaps
|
|
@@ -282,7 +282,7 @@ class Rect extends Polygon {
|
|
|
282
282
|
/**
|
|
283
283
|
* Returns true if the rectangle contains the given rectangle
|
|
284
284
|
* @name contains
|
|
285
|
-
* @memberof Rect
|
|
285
|
+
* @memberof Rect
|
|
286
286
|
* @function
|
|
287
287
|
* @param {Rect} rect
|
|
288
288
|
* @returns {boolean} true if contains
|
|
@@ -291,7 +291,7 @@ class Rect extends Polygon {
|
|
|
291
291
|
/**
|
|
292
292
|
* Returns true if the rectangle contains the given point
|
|
293
293
|
* @name contains
|
|
294
|
-
* @memberof Rect
|
|
294
|
+
* @memberof Rect
|
|
295
295
|
* @function
|
|
296
296
|
* @param {number} x x coordinate
|
|
297
297
|
* @param {number} y y coordinate
|
|
@@ -301,7 +301,7 @@ class Rect extends Polygon {
|
|
|
301
301
|
/**
|
|
302
302
|
* Returns true if the rectangle contains the given point
|
|
303
303
|
* @name contains
|
|
304
|
-
* @memberof Rect
|
|
304
|
+
* @memberof Rect
|
|
305
305
|
* @function
|
|
306
306
|
* @param {Vector2d} point
|
|
307
307
|
* @returns {boolean} true if contains
|
|
@@ -337,7 +337,7 @@ class Rect extends Polygon {
|
|
|
337
337
|
/**
|
|
338
338
|
* check if this rectangle is identical to the specified one
|
|
339
339
|
* @name equals
|
|
340
|
-
* @memberof Rect
|
|
340
|
+
* @memberof Rect
|
|
341
341
|
* @function
|
|
342
342
|
* @param {Rect} rect
|
|
343
343
|
* @returns {boolean} true if equals
|
|
@@ -354,7 +354,7 @@ class Rect extends Polygon {
|
|
|
354
354
|
/**
|
|
355
355
|
* determines whether all coordinates of this rectangle are finite numbers.
|
|
356
356
|
* @name isFinite
|
|
357
|
-
* @memberof Rect
|
|
357
|
+
* @memberof Rect
|
|
358
358
|
* @function
|
|
359
359
|
* @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
360
360
|
*/
|
|
@@ -365,7 +365,7 @@ class Rect extends Polygon {
|
|
|
365
365
|
/**
|
|
366
366
|
* Returns a polygon whose edges are the same as this box.
|
|
367
367
|
* @name toPolygon
|
|
368
|
-
* @memberof Rect
|
|
368
|
+
* @memberof Rect
|
|
369
369
|
* @function
|
|
370
370
|
* @returns {Polygon} a new Polygon that represents this rectangle.
|
|
371
371
|
*/
|
|
@@ -36,7 +36,7 @@ class RoundRect extends Rect {
|
|
|
36
36
|
* @type {number}
|
|
37
37
|
* @default 20
|
|
38
38
|
* @name radius
|
|
39
|
-
* @memberof RoundRect
|
|
39
|
+
* @memberof RoundRect
|
|
40
40
|
*/
|
|
41
41
|
get radius() {
|
|
42
42
|
return this._radius;
|
|
@@ -55,7 +55,7 @@ class RoundRect extends Rect {
|
|
|
55
55
|
/**
|
|
56
56
|
* copy the position, size and radius of the given rounded rectangle into this one
|
|
57
57
|
* @name copy
|
|
58
|
-
* @memberof RoundRect
|
|
58
|
+
* @memberof RoundRect
|
|
59
59
|
* @function
|
|
60
60
|
* @param {RoundRect} rrect source rounded rectangle
|
|
61
61
|
* @returns {RoundRect} new rectangle
|
|
@@ -69,7 +69,7 @@ class RoundRect extends Rect {
|
|
|
69
69
|
/**
|
|
70
70
|
* Returns true if the rounded rectangle contains the given point
|
|
71
71
|
* @name contains
|
|
72
|
-
* @memberof RoundRect
|
|
72
|
+
* @memberof RoundRect
|
|
73
73
|
* @function
|
|
74
74
|
* @param {number} x x coordinate
|
|
75
75
|
* @param {number} y y coordinate
|
|
@@ -79,7 +79,7 @@ class RoundRect extends Rect {
|
|
|
79
79
|
/**
|
|
80
80
|
* Returns true if the rounded rectangle contains the given point
|
|
81
81
|
* @name contains
|
|
82
|
-
* @memberof RoundRect
|
|
82
|
+
* @memberof RoundRect
|
|
83
83
|
* @function
|
|
84
84
|
* @param {Vector2d} point
|
|
85
85
|
* @returns {boolean} true if contains
|
|
@@ -140,7 +140,7 @@ class RoundRect extends Rect {
|
|
|
140
140
|
/**
|
|
141
141
|
* check if this RoundRect is identical to the specified one
|
|
142
142
|
* @name equals
|
|
143
|
-
* @memberof RoundRect
|
|
143
|
+
* @memberof RoundRect
|
|
144
144
|
* @function
|
|
145
145
|
* @param {RoundRect} rrect
|
|
146
146
|
* @returns {boolean} true if equals
|
|
@@ -152,7 +152,7 @@ class RoundRect extends Rect {
|
|
|
152
152
|
/**
|
|
153
153
|
* clone this RoundRect
|
|
154
154
|
* @name clone
|
|
155
|
-
* @memberof RoundRect
|
|
155
|
+
* @memberof RoundRect
|
|
156
156
|
* @function
|
|
157
157
|
* @returns {RoundRect} new RoundRect
|
|
158
158
|
*/
|
package/src/index.js
CHANGED
|
@@ -41,7 +41,8 @@ import WebGLCompositor from "./video/webgl/webgl_compositor.js";
|
|
|
41
41
|
import Renderer from "./video/renderer.js";
|
|
42
42
|
import WebGLRenderer from "./video/webgl/webgl_renderer.js";
|
|
43
43
|
import CanvasRenderer from "./video/canvas/canvas_renderer.js";
|
|
44
|
-
import
|
|
44
|
+
import CanvasTexture from "./video/texture/canvas_texture.js";
|
|
45
|
+
import { TextureAtlas } from "./video/texture/atlas.js";
|
|
45
46
|
import Renderable from "./renderable/renderable.js";
|
|
46
47
|
import Text from "./text/text.js";
|
|
47
48
|
import BitmapText from "./text/bitmaptext.js";
|
|
@@ -53,6 +54,7 @@ import NineSliceSprite from "./renderable/nineslicesprite.js";
|
|
|
53
54
|
import GUI_Object from "./renderable/GUI.js";
|
|
54
55
|
import Collectable from "./renderable/collectable.js";
|
|
55
56
|
import Trigger from "./renderable/trigger.js";
|
|
57
|
+
import Light2d from "./renderable/light2d.js";
|
|
56
58
|
import { Draggable, DropTarget } from "./renderable/dragndrop.js";
|
|
57
59
|
import TMXRenderer from "./level/tiled/renderer/TMXRenderer.js";
|
|
58
60
|
import TMXOrthogonalRenderer from "./level/tiled/renderer/TMXOrthogonalRenderer.js";
|
|
@@ -140,6 +142,7 @@ export {
|
|
|
140
142
|
GUI_Object,
|
|
141
143
|
Collectable,
|
|
142
144
|
Trigger,
|
|
145
|
+
Light2d,
|
|
143
146
|
Draggable,
|
|
144
147
|
DropTarget,
|
|
145
148
|
TMXRenderer,
|
|
@@ -202,6 +205,7 @@ export function boot() {
|
|
|
202
205
|
pool.register("me.Entity", Entity);
|
|
203
206
|
pool.register("me.Collectable", Collectable);
|
|
204
207
|
pool.register("me.Trigger", Trigger);
|
|
208
|
+
pool.register("me.Light2d", Light2d);
|
|
205
209
|
pool.register("me.Tween", Tween, true);
|
|
206
210
|
pool.register("me.Color", Color, true);
|
|
207
211
|
pool.register("me.Particle", Particle, true);
|
|
@@ -230,6 +234,7 @@ export function boot() {
|
|
|
230
234
|
pool.register("Entity", Entity);
|
|
231
235
|
pool.register("Collectable", Collectable);
|
|
232
236
|
pool.register("Trigger", Trigger);
|
|
237
|
+
pool.register("Light2d", Light2d);
|
|
233
238
|
pool.register("Tween", Tween, true);
|
|
234
239
|
pool.register("Color", Color, true);
|
|
235
240
|
pool.register("Particle", Particle, true);
|
|
@@ -253,6 +258,7 @@ export function boot() {
|
|
|
253
258
|
pool.register("Line", Line, true);
|
|
254
259
|
pool.register("Ellipse", Ellipse, true);
|
|
255
260
|
pool.register("Bounds", Bounds, true);
|
|
261
|
+
pool.register("CanvasTexture", CanvasTexture, true);
|
|
256
262
|
|
|
257
263
|
// publish Boot notification
|
|
258
264
|
event.emit(event.BOOT);
|
package/src/lang/deprecated.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import device from "./../system/device.js";
|
|
2
2
|
import { requestPointerLock, exitPointerLock } from "./../input/input.js";
|
|
3
|
-
import { TextureAtlas } from "./../video/texture.js";
|
|
3
|
+
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
4
4
|
import Renderer from "./../video/renderer.js";
|
|
5
5
|
import { Draggable, DropTarget } from "./../renderable/dragndrop.js";
|
|
6
6
|
|
|
@@ -47,9 +47,10 @@ export function warning(deprecated, replacement, version) {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* @public
|
|
50
|
-
* @type {Function}
|
|
51
50
|
* @name turnOnPointerLock
|
|
52
|
-
* @
|
|
51
|
+
* @function
|
|
52
|
+
* @returns {boolean} return true if the request was successfully submitted
|
|
53
|
+
* @memberof device#
|
|
53
54
|
* @deprecated since 10.3.0
|
|
54
55
|
* @see input.requestPointerLock
|
|
55
56
|
*/
|
|
@@ -60,9 +61,10 @@ device.turnOnPointerLock = function () {
|
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* @public
|
|
63
|
-
* @type {Function}
|
|
64
64
|
* @name turnOffPointerLock
|
|
65
|
-
* @
|
|
65
|
+
* @function
|
|
66
|
+
* @returns {boolean} return true if the request was successfully submitted
|
|
67
|
+
* @memberof device#
|
|
66
68
|
* @deprecated since 10.3.0
|
|
67
69
|
* @see input.exitPointerLock
|
|
68
70
|
*/
|
|
@@ -48,7 +48,7 @@ function setTMXValue(name, type, value) {
|
|
|
48
48
|
match = value.split(/^eval:/i)[1];
|
|
49
49
|
try {
|
|
50
50
|
// eslint-disable-next-line
|
|
51
|
-
value =
|
|
51
|
+
value = Function("'use strict';return (" + match + ")")();
|
|
52
52
|
}
|
|
53
53
|
catch (e) {
|
|
54
54
|
throw new Error("Unable to evaluate: " + match);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { world, viewport } from "./../game.js";
|
|
2
|
-
import {
|
|
2
|
+
import { renderer } from "./../video/video.js";
|
|
3
3
|
import * as event from "./../system/event.js";
|
|
4
4
|
import {nextPowerOfTwo} from "./../math/math.js";
|
|
5
5
|
import pool from "./../system/pooling.js";
|
|
@@ -69,13 +69,13 @@ class IconLogo extends Renderable {
|
|
|
69
69
|
constructor(x, y) {
|
|
70
70
|
super(x, y, 100, 85);
|
|
71
71
|
|
|
72
|
-
this.
|
|
72
|
+
this.iconTexture = pool.pull("CanvasTexture",
|
|
73
73
|
renderer.WebGLVersion > 1 ? this.width : nextPowerOfTwo(this.width),
|
|
74
74
|
renderer.WebGLVersion > 1 ? this.height : nextPowerOfTwo(this.height),
|
|
75
|
-
|
|
75
|
+
true
|
|
76
76
|
);
|
|
77
77
|
|
|
78
|
-
var context =
|
|
78
|
+
var context = this.iconTexture.context;
|
|
79
79
|
|
|
80
80
|
context.beginPath();
|
|
81
81
|
context.moveTo(0.7, 48.9);
|
|
@@ -110,7 +110,18 @@ class IconLogo extends Renderable {
|
|
|
110
110
|
* @ignore
|
|
111
111
|
*/
|
|
112
112
|
draw(renderer) {
|
|
113
|
-
renderer.drawImage(this.
|
|
113
|
+
renderer.drawImage(this.iconTexture.canvas, renderer.getWidth() / 2, this.pos.y);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Destroy function
|
|
118
|
+
* @ignore
|
|
119
|
+
*/
|
|
120
|
+
destroy() {
|
|
121
|
+
// call the parent destroy method
|
|
122
|
+
super.destroy(arguments);
|
|
123
|
+
pool.push(this.iconTexture);
|
|
124
|
+
this.iconTexture = undefined;
|
|
114
125
|
}
|
|
115
126
|
};
|
|
116
127
|
|
package/src/math/color.js
CHANGED
|
@@ -561,11 +561,11 @@ class Color {
|
|
|
561
561
|
* @function
|
|
562
562
|
* @returns {string}
|
|
563
563
|
*/
|
|
564
|
-
toHex8() {
|
|
564
|
+
toHex8(alpha = this.alpha) {
|
|
565
565
|
// TODO : Memoize this function by caching its result until any of
|
|
566
566
|
// the r,g,b,a values are changed
|
|
567
567
|
|
|
568
|
-
return "#" + toHex(this.r) + toHex(this.g) + toHex(this.b) + toHex(
|
|
568
|
+
return "#" + toHex(this.r) + toHex(this.g) + toHex(this.b) + toHex(alpha * 255);
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
/**
|
|
@@ -591,9 +591,10 @@ class Color {
|
|
|
591
591
|
* @name toRGBA
|
|
592
592
|
* @memberof Color
|
|
593
593
|
* @function
|
|
594
|
+
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
594
595
|
* @returns {string}
|
|
595
596
|
*/
|
|
596
|
-
toRGBA() {
|
|
597
|
+
toRGBA(alpha = this.alpha) {
|
|
597
598
|
// TODO : Memoize this function by caching its result until any of
|
|
598
599
|
// the r,g,b,a values are changed
|
|
599
600
|
|
|
@@ -601,7 +602,7 @@ class Color {
|
|
|
601
602
|
this.r + "," +
|
|
602
603
|
this.g + "," +
|
|
603
604
|
this.b + "," +
|
|
604
|
-
|
|
605
|
+
alpha +
|
|
605
606
|
")";
|
|
606
607
|
}
|
|
607
608
|
};
|
package/src/particles/emitter.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import { createCanvas } from "./../video/video.js";
|
|
2
1
|
import pool from "./../system/pooling.js";
|
|
3
2
|
import ParticleEmitterSettings from "./settings.js";
|
|
4
3
|
import { randomFloat } from "./../math/math.js";
|
|
5
4
|
import Container from "./../renderable/container.js";
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
// default texture used when no sprite is defined
|
|
9
|
-
let defaultParticleTexture;
|
|
10
|
-
|
|
11
7
|
/**
|
|
12
8
|
* @ignore
|
|
13
9
|
*/
|
|
14
10
|
function createDefaultParticleTexture(w = 8, h = 8) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
11
|
+
var defaultParticleTexture = pool.pull("CanvasTexture", w, h, true);
|
|
12
|
+
|
|
13
|
+
defaultParticleTexture.context.fillStyle = "#fff";
|
|
14
|
+
defaultParticleTexture.context.fillRect(0, 0, w, h);
|
|
15
|
+
|
|
21
16
|
return defaultParticleTexture;
|
|
22
17
|
};
|
|
23
18
|
|
|
@@ -120,9 +115,9 @@ class ParticleEmitter extends Container {
|
|
|
120
115
|
reset(settings = {}) {
|
|
121
116
|
Object.assign(this.settings, ParticleEmitterSettings, settings);
|
|
122
117
|
|
|
123
|
-
// Cache the image reference
|
|
124
118
|
if (typeof this.settings.image === "undefined") {
|
|
125
|
-
this.
|
|
119
|
+
this._defaultParticle = createDefaultParticleTexture(settings.textureSize, settings.textureSize);
|
|
120
|
+
this.settings.image = this._defaultParticle.canvas;
|
|
126
121
|
}
|
|
127
122
|
|
|
128
123
|
this.floating = this.settings.floating;
|
|
@@ -252,6 +247,10 @@ class ParticleEmitter extends Container {
|
|
|
252
247
|
// call the parent destroy method
|
|
253
248
|
super.destroy(arguments);
|
|
254
249
|
// clean emitter specific Properties
|
|
250
|
+
if (typeof this._defaultParticle !== "undefined") {
|
|
251
|
+
pool.push(this._defaultParticle);
|
|
252
|
+
this._defaultParticle = undefined;
|
|
253
|
+
}
|
|
255
254
|
this.settings.image = undefined;
|
|
256
255
|
this.settings = undefined;
|
|
257
256
|
}
|
package/src/renderable/GUI.js
CHANGED
|
@@ -116,7 +116,7 @@ class GUI_Object extends Sprite {
|
|
|
116
116
|
/**
|
|
117
117
|
* function called when the object is pressed (to be extended)
|
|
118
118
|
* @name onClick
|
|
119
|
-
* @memberof GUI_Object
|
|
119
|
+
* @memberof GUI_Object
|
|
120
120
|
* @public
|
|
121
121
|
* @function
|
|
122
122
|
* @param {Pointer} event the event object
|
|
@@ -139,7 +139,7 @@ class GUI_Object extends Sprite {
|
|
|
139
139
|
/**
|
|
140
140
|
* function called when the pointer is over the object
|
|
141
141
|
* @name onOver
|
|
142
|
-
* @memberof GUI_Object
|
|
142
|
+
* @memberof GUI_Object
|
|
143
143
|
* @public
|
|
144
144
|
* @function
|
|
145
145
|
* @param {Pointer} event the event object
|
|
@@ -160,7 +160,7 @@ class GUI_Object extends Sprite {
|
|
|
160
160
|
/**
|
|
161
161
|
* function called when the pointer is leaving the object area
|
|
162
162
|
* @name onOut
|
|
163
|
-
* @memberof GUI_Object
|
|
163
|
+
* @memberof GUI_Object
|
|
164
164
|
* @public
|
|
165
165
|
* @function
|
|
166
166
|
* @param {Pointer} event the event object
|
|
@@ -185,7 +185,7 @@ class GUI_Object extends Sprite {
|
|
|
185
185
|
/**
|
|
186
186
|
* function called when the object is pressed and released (to be extended)
|
|
187
187
|
* @name onRelease
|
|
188
|
-
* @memberof GUI_Object
|
|
188
|
+
* @memberof GUI_Object
|
|
189
189
|
* @public
|
|
190
190
|
* @function
|
|
191
191
|
* @returns {boolean} return false if we need to stop propagating the event
|
|
@@ -210,7 +210,7 @@ class GUI_Object extends Sprite {
|
|
|
210
210
|
* function called when the object is pressed and held<br>
|
|
211
211
|
* to be extended <br>
|
|
212
212
|
* @name onHold
|
|
213
|
-
* @memberof GUI_Object
|
|
213
|
+
* @memberof GUI_Object
|
|
214
214
|
* @public
|
|
215
215
|
* @function
|
|
216
216
|
*/
|