melonjs 10.2.0 → 10.3.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 +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
package/src/physics/sat.js
CHANGED
|
@@ -26,7 +26,7 @@ var RIGHT_VORNOI_REGION = 1;
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* A pool of `Vector` objects that are used in calculations to avoid allocating memory.
|
|
29
|
-
* @type {Array.<
|
|
29
|
+
* @type {Array.<me.Vector2d>}
|
|
30
30
|
* @ignore
|
|
31
31
|
*/
|
|
32
32
|
var T_VECTORS = [];
|
|
@@ -46,8 +46,8 @@ for (var a = 0; a < 5; a++) { T_ARRAYS.push([]); }
|
|
|
46
46
|
* resulting in a one dimensional range of the minimum and
|
|
47
47
|
* maximum value on that axis.
|
|
48
48
|
* @ignore
|
|
49
|
-
* @param {Array.<
|
|
50
|
-
* @param {
|
|
49
|
+
* @param {Array.<me.Vector2d>} points The points to flatten.
|
|
50
|
+
* @param {me.Vector2d} normal The unit vector axis to flatten on.
|
|
51
51
|
* @param {Array.<number>} result An array. After calling this function,
|
|
52
52
|
* result[0] will be the minimum value,
|
|
53
53
|
* result[1] will be the maximum value.
|
|
@@ -58,7 +58,7 @@ function flattenPointsOn(points, normal, result) {
|
|
|
58
58
|
var len = points.length;
|
|
59
59
|
for (var i = 0; i < len; i++) {
|
|
60
60
|
// The magnitude of the projection of the point onto the normal
|
|
61
|
-
var dot = points[i].
|
|
61
|
+
var dot = points[i].dot(normal);
|
|
62
62
|
if (dot < min) { min = dot; }
|
|
63
63
|
if (dot > max) { max = dot; }
|
|
64
64
|
}
|
|
@@ -70,15 +70,15 @@ function flattenPointsOn(points, normal, result) {
|
|
|
70
70
|
* Check whether two convex polygons are separated by the specified
|
|
71
71
|
* axis (must be a unit vector).
|
|
72
72
|
* @ignore
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {
|
|
75
|
-
* @param {Array.<
|
|
76
|
-
* @param {Array.<
|
|
77
|
-
* @param {
|
|
73
|
+
* @param {me.Vector2d} aPos The position of the first polygon.
|
|
74
|
+
* @param {me.Vector2d} bPos The position of the second polygon.
|
|
75
|
+
* @param {Array.<me.Vector2d>} aPoints The points in the first polygon.
|
|
76
|
+
* @param {Array.<me.Vector2d>} bPoints The points in the second polygon.
|
|
77
|
+
* @param {me.Vector2d} axis The axis (unit sized) to test against. The points of both polygons
|
|
78
78
|
* will be projected onto this axis.
|
|
79
79
|
* @param {Response=} response A Response object (optional) which will be populated
|
|
80
80
|
* if the axis is not a separating axis.
|
|
81
|
-
* @
|
|
81
|
+
* @returns {boolean} true if it is a separating axis, false otherwise. If false,
|
|
82
82
|
* and a response is passed in, information about how much overlap and
|
|
83
83
|
* the direction of the overlap will be populated.
|
|
84
84
|
*/
|
|
@@ -87,7 +87,7 @@ function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
|
|
|
87
87
|
var rangeB = T_ARRAYS.pop();
|
|
88
88
|
// The magnitude of the offset between the two polygons
|
|
89
89
|
var offsetV = T_VECTORS.pop().copy(bPos).sub(aPos);
|
|
90
|
-
var projectedOffset = offsetV.
|
|
90
|
+
var projectedOffset = offsetV.dot(axis);
|
|
91
91
|
|
|
92
92
|
// Project the polygons onto the axis.
|
|
93
93
|
flattenPointsOn(aPoints, axis, rangeA);
|
|
@@ -161,15 +161,15 @@ function isSeparatingAxis(aPos, bPos, aPoints, bPoints, axis, response) {
|
|
|
161
161
|
* </pre>
|
|
162
162
|
*
|
|
163
163
|
* @ignore
|
|
164
|
-
* @param {
|
|
165
|
-
* @param {
|
|
166
|
-
* @
|
|
164
|
+
* @param {me.Vector2d} line The line segment.
|
|
165
|
+
* @param {me.Vector2d} point The point.
|
|
166
|
+
* @returns {number} LEFT_VORNOI_REGION (-1) if it is the left region,
|
|
167
167
|
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
|
168
168
|
* RIGHT_VORNOI_REGION (1) if it is the right region.
|
|
169
169
|
*/
|
|
170
170
|
function vornoiRegion(line, point) {
|
|
171
171
|
var len2 = line.length2();
|
|
172
|
-
var dp = point.
|
|
172
|
+
var dp = point.dot(line);
|
|
173
173
|
if (dp < 0) {
|
|
174
174
|
// If the point is beyond the start of the line, it is in the
|
|
175
175
|
// left vornoi region.
|
|
@@ -192,7 +192,7 @@ function vornoiRegion(line, point) {
|
|
|
192
192
|
* @param {me.Renderable} b a reference to the object B.
|
|
193
193
|
* @param {me.Polygon} polyB a reference to the object B Polygon to be tested
|
|
194
194
|
* @param {Response=} response Response object (optional) that will be populated if they intersect.
|
|
195
|
-
* @
|
|
195
|
+
* @returns {boolean} true if they intersect, false if they don't.
|
|
196
196
|
*/
|
|
197
197
|
export function testPolygonPolygon(a, polyA, b, polyB, response) {
|
|
198
198
|
// specific point for
|
|
@@ -247,7 +247,7 @@ export function testPolygonPolygon(a, polyA, b, polyB, response) {
|
|
|
247
247
|
* @param {me.Ellipse} ellipseB a reference to the object B Ellipse to be tested
|
|
248
248
|
* @param {Response=} response Response object (optional) that will be populated if
|
|
249
249
|
* the circles intersect.
|
|
250
|
-
* @
|
|
250
|
+
* @returns {boolean} true if the circles intersect, false if they don't.
|
|
251
251
|
*/
|
|
252
252
|
export function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
|
|
253
253
|
// Check if the distance between the centers of the two
|
|
@@ -287,7 +287,7 @@ export function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
|
|
|
287
287
|
* @param {me.Renderable} b a reference to the object B.
|
|
288
288
|
* @param {me.Ellipse} ellipseB a reference to the object B Ellipse to be tested
|
|
289
289
|
* @param {Response=} response Response object (optional) that will be populated if they intersect.
|
|
290
|
-
* @
|
|
290
|
+
* @returns {boolean} true if they intersect, false if they don't.
|
|
291
291
|
*/
|
|
292
292
|
export function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
293
293
|
// Get the position of the circle relative to the polygon.
|
|
@@ -400,7 +400,7 @@ export function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
400
400
|
normal.copy(polyA.normals[i]);
|
|
401
401
|
// Find the perpendicular distance between the center of the
|
|
402
402
|
// circle and the edge.
|
|
403
|
-
dist = point.
|
|
403
|
+
dist = point.dot(normal);
|
|
404
404
|
var distAbs = Math.abs(dist);
|
|
405
405
|
// If the circle is on the outside of the edge, there is no intersection.
|
|
406
406
|
if ((len === 1 || dist > 0) && distAbs > radius) {
|
|
@@ -450,11 +450,11 @@ export function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
450
450
|
* @ignore
|
|
451
451
|
* @param {me.Renderable} a a reference to the object A.
|
|
452
452
|
* @param {me.Ellipse} ellipseA a reference to the object A Ellipse to be tested
|
|
453
|
-
* @param {me.Renderable}
|
|
453
|
+
* @param {me.Renderable} b a reference to the object B.
|
|
454
454
|
* @param {me.Polygon} polyB a reference to the object B Polygon to be tested
|
|
455
455
|
* @param {Response=} response Response object (optional) that will be populated if
|
|
456
456
|
* they intersect.
|
|
457
|
-
* @
|
|
457
|
+
* @returns {boolean} true if they intersect, false if they don't.
|
|
458
458
|
*/
|
|
459
459
|
export function testEllipsePolygon(a, ellipseA, b, polyB, response) {
|
|
460
460
|
// Test the polygon against the circle.
|
package/src/physics/world.js
CHANGED
|
@@ -7,16 +7,15 @@ import { collisionCheck } from "./detector.js";
|
|
|
7
7
|
import state from "./../state/state.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @classdesc
|
|
10
|
+
* @classdesc
|
|
11
11
|
* an object representing the physic world, and responsible for managing and updating all childs and physics
|
|
12
12
|
* @class World
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {Number} [h=me.game.viewport.height] height of the container
|
|
13
|
+
* @augments me.Container
|
|
14
|
+
* @memberof me
|
|
15
|
+
* @param {number} [x=0] position of the container (accessible via the inherited pos.x property)
|
|
16
|
+
* @param {number} [y=0] position of the container (accessible via the inherited pos.y property)
|
|
17
|
+
* @param {number} [w=me.game.viewport.width] width of the container
|
|
18
|
+
* @param {number} [h=me.game.viewport.height] height of the container
|
|
20
19
|
*/
|
|
21
20
|
class World extends Container {
|
|
22
21
|
/**
|
|
@@ -37,10 +36,10 @@ class World extends Container {
|
|
|
37
36
|
* the rate at which the game world is updated,
|
|
38
37
|
* may be greater than or lower than the display fps
|
|
39
38
|
* @public
|
|
40
|
-
* @type me.Vector2d
|
|
39
|
+
* @type {me.Vector2d}
|
|
41
40
|
* @default 60
|
|
42
41
|
* @name fps
|
|
43
|
-
* @
|
|
42
|
+
* @memberof me.World
|
|
44
43
|
* @see me.timer.maxfps
|
|
45
44
|
*/
|
|
46
45
|
this.fps = 60;
|
|
@@ -48,10 +47,10 @@ class World extends Container {
|
|
|
48
47
|
/**
|
|
49
48
|
* world gravity
|
|
50
49
|
* @public
|
|
51
|
-
* @type me.Vector2d
|
|
50
|
+
* @type {me.Vector2d}
|
|
52
51
|
* @default <0,0.98>
|
|
53
52
|
* @name gravity
|
|
54
|
-
* @
|
|
53
|
+
* @memberof me.World
|
|
55
54
|
*/
|
|
56
55
|
this.gravity = new Vector2d(0, 0.98);
|
|
57
56
|
|
|
@@ -63,16 +62,16 @@ class World extends Container {
|
|
|
63
62
|
* (amount of layer, layer size, amount of tiles per layer, etc.)<br>
|
|
64
63
|
* note : rendering method is also configurable per layer by adding this
|
|
65
64
|
* property to your layer (in Tiled).
|
|
66
|
-
* @type {
|
|
65
|
+
* @type {boolean}
|
|
67
66
|
* @default false
|
|
68
|
-
* @
|
|
67
|
+
* @memberof me.World
|
|
69
68
|
*/
|
|
70
69
|
this.preRender = false;
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
72
|
* the active physic bodies in this simulation
|
|
74
73
|
* @name bodies
|
|
75
|
-
* @
|
|
74
|
+
* @memberof me.World
|
|
76
75
|
* @public
|
|
77
76
|
* @type {Set}
|
|
78
77
|
*/
|
|
@@ -81,7 +80,7 @@ class World extends Container {
|
|
|
81
80
|
/**
|
|
82
81
|
* the instance of the game world quadtree used for broadphase
|
|
83
82
|
* @name broadphase
|
|
84
|
-
* @
|
|
83
|
+
* @memberof me.World
|
|
85
84
|
* @public
|
|
86
85
|
* @type {me.QuadTree}
|
|
87
86
|
*/
|
|
@@ -100,7 +99,7 @@ class World extends Container {
|
|
|
100
99
|
/**
|
|
101
100
|
* reset the game world
|
|
102
101
|
* @name reset
|
|
103
|
-
* @
|
|
102
|
+
* @memberof me.World
|
|
104
103
|
* @function
|
|
105
104
|
*/
|
|
106
105
|
reset() {
|
|
@@ -121,11 +120,11 @@ class World extends Container {
|
|
|
121
120
|
/**
|
|
122
121
|
* Add a physic body to the game world
|
|
123
122
|
* @name addBody
|
|
124
|
-
* @
|
|
123
|
+
* @memberof me.World
|
|
125
124
|
* @see me.Container.addChild
|
|
126
125
|
* @function
|
|
127
126
|
* @param {me.Body} body
|
|
128
|
-
* @
|
|
127
|
+
* @returns {me.World} this game world
|
|
129
128
|
*/
|
|
130
129
|
addBody(body) {
|
|
131
130
|
//add it to the list of active body
|
|
@@ -136,11 +135,11 @@ class World extends Container {
|
|
|
136
135
|
/**
|
|
137
136
|
* Remove a physic body from the game world
|
|
138
137
|
* @name removeBody
|
|
139
|
-
* @
|
|
138
|
+
* @memberof me.World
|
|
140
139
|
* @see me.Container.removeChild
|
|
141
140
|
* @function
|
|
142
141
|
* @param {me.Body} body
|
|
143
|
-
* @
|
|
142
|
+
* @returns {me.World} this game world
|
|
144
143
|
*/
|
|
145
144
|
removeBody(body) {
|
|
146
145
|
//remove from the list of active body
|
|
@@ -151,8 +150,10 @@ class World extends Container {
|
|
|
151
150
|
/**
|
|
152
151
|
* update the game world
|
|
153
152
|
* @name reset
|
|
154
|
-
* @
|
|
153
|
+
* @memberof me.World
|
|
155
154
|
* @function
|
|
155
|
+
* @param {number} dt the time passed since the last frame update
|
|
156
|
+
* @returns {boolean} true if the word is dirty
|
|
156
157
|
*/
|
|
157
158
|
update (dt) {
|
|
158
159
|
var isPaused = state.isPaused();
|
package/src/plugin/plugin.js
CHANGED
|
@@ -5,7 +5,7 @@ import { version } from "./../index.js";
|
|
|
5
5
|
* This namespace is a container for all registered plugins.
|
|
6
6
|
* @see me.plugin.register
|
|
7
7
|
* @namespace me.plugins
|
|
8
|
-
* @
|
|
8
|
+
* @memberof me
|
|
9
9
|
*/
|
|
10
10
|
export var plugins = {};
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ class BasePlugin {
|
|
|
17
17
|
* define the minimum required version of melonJS<br>
|
|
18
18
|
* this can be overridden by the plugin
|
|
19
19
|
* @public
|
|
20
|
-
* @type
|
|
20
|
+
* @type {string}
|
|
21
21
|
* @default "__VERSION__"
|
|
22
22
|
* @name me.plugin.Base#version
|
|
23
23
|
*/
|
|
@@ -27,7 +27,7 @@ class BasePlugin {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* @namespace plugin
|
|
30
|
-
* @
|
|
30
|
+
* @memberof me
|
|
31
31
|
*/
|
|
32
32
|
export var plugin = {
|
|
33
33
|
|
|
@@ -36,21 +36,20 @@ export var plugin = {
|
|
|
36
36
|
* plugin must be installed using the register function
|
|
37
37
|
* @see me.plugin
|
|
38
38
|
* @class
|
|
39
|
-
* @
|
|
39
|
+
* @augments me.Object
|
|
40
40
|
* @name plugin.Base
|
|
41
|
-
* @
|
|
42
|
-
* @constructor
|
|
41
|
+
* @memberof me
|
|
43
42
|
*/
|
|
44
43
|
Base : BasePlugin,
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
46
|
* patch a melonJS function
|
|
48
47
|
* @name patch
|
|
49
|
-
* @
|
|
48
|
+
* @memberof me.plugin
|
|
50
49
|
* @public
|
|
51
50
|
* @function
|
|
52
|
-
* @param {
|
|
53
|
-
* @param {
|
|
51
|
+
* @param {object} proto target object
|
|
52
|
+
* @param {string} name target function
|
|
54
53
|
* @param {Function} fn replacement function
|
|
55
54
|
* @example
|
|
56
55
|
* // redefine the me.game.update function with a new one
|
|
@@ -91,13 +90,13 @@ export var plugin = {
|
|
|
91
90
|
/**
|
|
92
91
|
* Register a plugin.
|
|
93
92
|
* @name register
|
|
94
|
-
* @
|
|
93
|
+
* @memberof me.plugin
|
|
95
94
|
* @see me.plugin.Base
|
|
96
95
|
* @public
|
|
97
96
|
* @function
|
|
98
|
-
* @param {me.plugin.Base}
|
|
99
|
-
* @param {
|
|
100
|
-
* @param {} [arguments
|
|
97
|
+
* @param {me.plugin.Base} pluginObj Plugin object to instantiate and register
|
|
98
|
+
* @param {string} name
|
|
99
|
+
* @param {object} [...arguments] all extra parameters will be passed to the plugin constructor
|
|
101
100
|
* @example
|
|
102
101
|
* // register a new plugin
|
|
103
102
|
* me.plugin.register(TestPlugin, "testPlugin");
|
package/src/renderable/GUI.js
CHANGED
|
@@ -10,14 +10,12 @@ import { registerPointerEvent, releasePointerEvent} from "./../input/input.js";
|
|
|
10
10
|
* The object simply register on the "pointerdown" <br>
|
|
11
11
|
* or "touchstart" event and call the onClick function"
|
|
12
12
|
* @class GUI_Object
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {Object} settings See {@link me.Sprite}
|
|
13
|
+
* @augments me.Sprite
|
|
14
|
+
* @memberof me
|
|
15
|
+
* @param {number} x the x coordinate of the GUI Object
|
|
16
|
+
* @param {number} y the y coordinate of the GUI Object
|
|
17
|
+
* @param {object} settings See {@link me.Sprite}
|
|
19
18
|
* @example
|
|
20
|
-
*
|
|
21
19
|
* // create a basic GUI Object
|
|
22
20
|
* class myButton extends GUI_Object {
|
|
23
21
|
* constructor(x, y) {
|
|
@@ -42,7 +40,6 @@ import { registerPointerEvent, releasePointerEvent} from "./../input/input.js";
|
|
|
42
40
|
*
|
|
43
41
|
* // add the object at pos (10,10)
|
|
44
42
|
* me.game.world.addChild(new myButton(10,10));
|
|
45
|
-
*
|
|
46
43
|
*/
|
|
47
44
|
|
|
48
45
|
class GUI_Object extends Sprite {
|
|
@@ -58,7 +55,7 @@ class GUI_Object extends Sprite {
|
|
|
58
55
|
/**
|
|
59
56
|
* object can be clicked or not
|
|
60
57
|
* @public
|
|
61
|
-
* @type boolean
|
|
58
|
+
* @type {boolean}
|
|
62
59
|
* @default true
|
|
63
60
|
* @name me.GUI_Object#isClickable
|
|
64
61
|
*/
|
|
@@ -75,7 +72,7 @@ class GUI_Object extends Sprite {
|
|
|
75
72
|
/**
|
|
76
73
|
* object can be tap and hold
|
|
77
74
|
* @public
|
|
78
|
-
* @type boolean
|
|
75
|
+
* @type {boolean}
|
|
79
76
|
* @default false
|
|
80
77
|
* @name me.GUI_Object#isHoldable
|
|
81
78
|
*/
|
|
@@ -84,7 +81,7 @@ class GUI_Object extends Sprite {
|
|
|
84
81
|
/**
|
|
85
82
|
* true if the pointer is over the object
|
|
86
83
|
* @public
|
|
87
|
-
* @type boolean
|
|
84
|
+
* @type {boolean}
|
|
88
85
|
* @default false
|
|
89
86
|
* @name me.GUI_Object#hover
|
|
90
87
|
*/
|
|
@@ -122,14 +119,13 @@ class GUI_Object extends Sprite {
|
|
|
122
119
|
}
|
|
123
120
|
|
|
124
121
|
/**
|
|
125
|
-
* function called when the object is pressed
|
|
126
|
-
* to be extended <br>
|
|
127
|
-
* return false if we need to stop propagating the event
|
|
122
|
+
* function called when the object is pressed (to be extended)
|
|
128
123
|
* @name onClick
|
|
129
|
-
* @
|
|
124
|
+
* @memberof me.GUI_Object.prototype
|
|
130
125
|
* @public
|
|
131
126
|
* @function
|
|
132
|
-
* @param {
|
|
127
|
+
* @param {me.Pointer} event the event object
|
|
128
|
+
* @returns {boolean} return false if we need to stop propagating the event
|
|
133
129
|
*/
|
|
134
130
|
onClick(/* event */) {
|
|
135
131
|
return false;
|
|
@@ -148,10 +144,10 @@ class GUI_Object extends Sprite {
|
|
|
148
144
|
/**
|
|
149
145
|
* function called when the pointer is over the object
|
|
150
146
|
* @name onOver
|
|
151
|
-
* @
|
|
147
|
+
* @memberof me.GUI_Object.prototype
|
|
152
148
|
* @public
|
|
153
149
|
* @function
|
|
154
|
-
* @param {
|
|
150
|
+
* @param {me.Pointer} event the event object
|
|
155
151
|
*/
|
|
156
152
|
onOver(/* event */) {}
|
|
157
153
|
|
|
@@ -169,10 +165,10 @@ class GUI_Object extends Sprite {
|
|
|
169
165
|
/**
|
|
170
166
|
* function called when the pointer is leaving the object area
|
|
171
167
|
* @name onOut
|
|
172
|
-
* @
|
|
168
|
+
* @memberof me.GUI_Object.prototype
|
|
173
169
|
* @public
|
|
174
170
|
* @function
|
|
175
|
-
* @param {
|
|
171
|
+
* @param {me.Pointer} event the event object
|
|
176
172
|
*/
|
|
177
173
|
onOut(/* event */) {
|
|
178
174
|
|
|
@@ -192,14 +188,12 @@ class GUI_Object extends Sprite {
|
|
|
192
188
|
}
|
|
193
189
|
|
|
194
190
|
/**
|
|
195
|
-
* function called when the object is pressed and released
|
|
196
|
-
* to be extended <br>
|
|
197
|
-
* return false if we need to stop propagating the event
|
|
191
|
+
* function called when the object is pressed and released (to be extended)
|
|
198
192
|
* @name onRelease
|
|
199
|
-
* @
|
|
193
|
+
* @memberof me.GUI_Object.prototype
|
|
200
194
|
* @public
|
|
201
195
|
* @function
|
|
202
|
-
* @
|
|
196
|
+
* @returns {boolean} return false if we need to stop propagating the event
|
|
203
197
|
*/
|
|
204
198
|
onRelease() {
|
|
205
199
|
return false;
|
|
@@ -221,7 +215,7 @@ class GUI_Object extends Sprite {
|
|
|
221
215
|
* function called when the object is pressed and held<br>
|
|
222
216
|
* to be extended <br>
|
|
223
217
|
* @name onHold
|
|
224
|
-
* @
|
|
218
|
+
* @memberof me.GUI_Object.prototype
|
|
225
219
|
* @public
|
|
226
220
|
* @function
|
|
227
221
|
*/
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import Sprite from "./sprite.js";
|
|
2
2
|
import Body from "./../physics/body.js";
|
|
3
|
-
import Rect from "./../
|
|
3
|
+
import Rect from "./../geometries/rectangle.js";
|
|
4
4
|
import collision from "./../physics/collision.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @classdesc
|
|
8
8
|
* a basic collectable helper class for immovable object (e.g. a coin)
|
|
9
9
|
* @class Collectable
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {Object} settings See {@link me.Sprite}
|
|
10
|
+
* @augments me.Sprite
|
|
11
|
+
* @memberof me
|
|
12
|
+
* @param {number} x the x coordinates of the collectable
|
|
13
|
+
* @param {number} y the y coordinates of the collectable
|
|
14
|
+
* @param {object} settings See {@link me.Sprite}
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
17
|
class Collectable extends Sprite {
|
|
@@ -7,12 +7,11 @@ import Renderable from "./renderable.js";
|
|
|
7
7
|
* @classdesc
|
|
8
8
|
* a generic Color Layer Object. Fills the entire Canvas with the color not just the container the object belongs to.
|
|
9
9
|
* @class ColorLayer
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {Number} [z = 0] z-index position
|
|
10
|
+
* @augments me.Renderable
|
|
11
|
+
* @memberof me
|
|
12
|
+
* @param {string} name Layer name
|
|
13
|
+
* @param {me.Color|string} color CSS color
|
|
14
|
+
* @param {number} [z = 0] z-index position
|
|
16
15
|
*/
|
|
17
16
|
class ColorLayer extends Renderable {
|
|
18
17
|
|
|
@@ -26,9 +25,9 @@ class ColorLayer extends Renderable {
|
|
|
26
25
|
/**
|
|
27
26
|
* the layer color component
|
|
28
27
|
* @public
|
|
29
|
-
* @type me.Color
|
|
28
|
+
* @type {me.Color}
|
|
30
29
|
* @name color
|
|
31
|
-
* @
|
|
30
|
+
* @memberof me.ColorLayer#
|
|
32
31
|
*/
|
|
33
32
|
this.color = pool.pull("Color").parseCSS(color);
|
|
34
33
|
|
|
@@ -50,14 +49,14 @@ class ColorLayer extends Renderable {
|
|
|
50
49
|
* @ignore
|
|
51
50
|
*/
|
|
52
51
|
draw(renderer, rect) {
|
|
53
|
-
var color = renderer.getColor();
|
|
54
52
|
var vpos = viewport.pos;
|
|
55
|
-
renderer.
|
|
56
|
-
renderer.
|
|
53
|
+
renderer.save();
|
|
54
|
+
renderer.clipRect(
|
|
57
55
|
rect.left - vpos.x, rect.top - vpos.y,
|
|
58
56
|
rect.width, rect.height
|
|
59
57
|
);
|
|
60
|
-
renderer.
|
|
58
|
+
renderer.clearColor(this.color);
|
|
59
|
+
renderer.restore();
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
/**
|