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/entity/draggable.js
CHANGED
|
@@ -4,26 +4,17 @@ import * as event from "./../system/event.js";
|
|
|
4
4
|
import Entity from "./entity.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
*/
|
|
7
|
+
* @classdesc
|
|
8
|
+
* Used to make a game entity draggable
|
|
9
|
+
* @class DraggableEntity
|
|
10
|
+
* @augments me.Entity
|
|
11
|
+
* @memberof me
|
|
12
|
+
* @param {number} x the x coordinates of the entity object
|
|
13
|
+
* @param {number} y the y coordinates of the entity object
|
|
14
|
+
* @param {object} settings Entity properties (see {@link me.Entity})
|
|
15
|
+
*/
|
|
16
16
|
class DraggableEntity extends Entity {
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Constructor
|
|
20
|
-
* @name init
|
|
21
|
-
* @memberOf me.DraggableEntity
|
|
22
|
-
* @function
|
|
23
|
-
* @param {Number} x the x postion of the entity
|
|
24
|
-
* @param {Number} y the y postion of the entity
|
|
25
|
-
* @param {Object} settings the additional entity settings
|
|
26
|
-
*/
|
|
27
18
|
constructor(x, y, settings) {
|
|
28
19
|
super(x, y, settings);
|
|
29
20
|
this.dragging = false;
|
|
@@ -41,7 +32,7 @@ class DraggableEntity extends Entity {
|
|
|
41
32
|
* this module testable. Then we subscribe this module to the
|
|
42
33
|
* transformed events.
|
|
43
34
|
* @name initEvents
|
|
44
|
-
* @
|
|
35
|
+
* @memberof me.DraggableEntity
|
|
45
36
|
* @function
|
|
46
37
|
*/
|
|
47
38
|
initEvents() {
|
|
@@ -68,10 +59,10 @@ class DraggableEntity extends Entity {
|
|
|
68
59
|
/**
|
|
69
60
|
* Translates a pointer event to a me.event
|
|
70
61
|
* @name translatePointerEvent
|
|
71
|
-
* @
|
|
62
|
+
* @memberof me.DraggableEntity
|
|
72
63
|
* @function
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {
|
|
64
|
+
* @param {object} e the pointer event you want to translate
|
|
65
|
+
* @param {string} translation the me.event you want to translate the event to
|
|
75
66
|
*/
|
|
76
67
|
translatePointerEvent(e, translation) {
|
|
77
68
|
event.emit(translation, e);
|
|
@@ -80,9 +71,10 @@ class DraggableEntity extends Entity {
|
|
|
80
71
|
/**
|
|
81
72
|
* Gets called when the user starts dragging the entity
|
|
82
73
|
* @name dragStart
|
|
83
|
-
* @
|
|
74
|
+
* @memberof me.DraggableEntity
|
|
84
75
|
* @function
|
|
85
|
-
* @param {
|
|
76
|
+
* @param {object} e the pointer event
|
|
77
|
+
* @returns {boolean} false if the object is being dragged
|
|
86
78
|
*/
|
|
87
79
|
dragStart(e) {
|
|
88
80
|
if (this.dragging === false) {
|
|
@@ -96,9 +88,9 @@ class DraggableEntity extends Entity {
|
|
|
96
88
|
/**
|
|
97
89
|
* Gets called when the user drags this entity around
|
|
98
90
|
* @name dragMove
|
|
99
|
-
* @
|
|
91
|
+
* @memberof me.DraggableEntity
|
|
100
92
|
* @function
|
|
101
|
-
* @param {
|
|
93
|
+
* @param {object} e the pointer event
|
|
102
94
|
*/
|
|
103
95
|
dragMove(e) {
|
|
104
96
|
if (this.dragging === true) {
|
|
@@ -110,9 +102,9 @@ class DraggableEntity extends Entity {
|
|
|
110
102
|
/**
|
|
111
103
|
* Gets called when the user stops dragging the entity
|
|
112
104
|
* @name dragEnd
|
|
113
|
-
* @
|
|
105
|
+
* @memberof me.DraggableEntity
|
|
114
106
|
* @function
|
|
115
|
-
* @
|
|
107
|
+
* @returns {boolean} false if the object stopped being dragged
|
|
116
108
|
*/
|
|
117
109
|
dragEnd() {
|
|
118
110
|
if (this.dragging === true) {
|
|
@@ -124,7 +116,7 @@ class DraggableEntity extends Entity {
|
|
|
124
116
|
/**
|
|
125
117
|
* Destructor
|
|
126
118
|
* @name destroy
|
|
127
|
-
* @
|
|
119
|
+
* @memberof me.DraggableEntity
|
|
128
120
|
* @function
|
|
129
121
|
*/
|
|
130
122
|
destroy() {
|
package/src/entity/droptarget.js
CHANGED
|
@@ -2,53 +2,45 @@ import * as event from "./../system/event.js";
|
|
|
2
2
|
import Entity from "./entity.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
*/
|
|
5
|
+
* @classdesc
|
|
6
|
+
* Used to make a game entity a droptarget
|
|
7
|
+
* @class DroptargetEntity
|
|
8
|
+
* @augments me.Entity
|
|
9
|
+
* @memberof me
|
|
10
|
+
* @param {number} x the x coordinates of the entity object
|
|
11
|
+
* @param {number} y the y coordinates of the entity object
|
|
12
|
+
* @param {object} settings Entity properties (see {@link me.Entity})
|
|
13
|
+
*/
|
|
14
14
|
|
|
15
15
|
class DroptargetEntity extends Entity {
|
|
16
|
-
|
|
17
|
-
* Constructor
|
|
18
|
-
* @name init
|
|
19
|
-
* @memberOf me.DroptargetEntity
|
|
20
|
-
* @function
|
|
21
|
-
* @param {Number} x the x postion of the entity
|
|
22
|
-
* @param {Number} y the y postion of the entity
|
|
23
|
-
* @param {Object} settings the additional entity settings
|
|
24
|
-
*/
|
|
16
|
+
|
|
25
17
|
constructor(x, y, settings) {
|
|
26
18
|
super(x, y, settings);
|
|
27
19
|
/**
|
|
28
20
|
* constant for the overlaps method
|
|
29
21
|
* @public
|
|
30
22
|
* @constant
|
|
31
|
-
* @type
|
|
23
|
+
* @type {string}
|
|
32
24
|
* @name CHECKMETHOD_OVERLAP
|
|
33
|
-
* @
|
|
25
|
+
* @memberof me.DroptargetEntity
|
|
34
26
|
*/
|
|
35
27
|
this.CHECKMETHOD_OVERLAP = "overlaps";
|
|
36
28
|
/**
|
|
37
29
|
* constant for the contains method
|
|
38
30
|
* @public
|
|
39
31
|
* @constant
|
|
40
|
-
* @type
|
|
32
|
+
* @type {string}
|
|
41
33
|
* @name CHECKMETHOD_CONTAINS
|
|
42
|
-
* @
|
|
34
|
+
* @memberof me.DroptargetEntity
|
|
43
35
|
*/
|
|
44
36
|
this.CHECKMETHOD_CONTAINS = "contains";
|
|
45
37
|
/**
|
|
46
38
|
* the checkmethod we want to use
|
|
47
39
|
* @public
|
|
48
40
|
* @constant
|
|
49
|
-
* @type
|
|
41
|
+
* @type {string}
|
|
50
42
|
* @name checkMethod
|
|
51
|
-
* @
|
|
43
|
+
* @memberof me.DroptargetEntity
|
|
52
44
|
*/
|
|
53
45
|
this.checkMethod = null;
|
|
54
46
|
event.on(event.DRAGEND, this.checkOnMe, this);
|
|
@@ -58,9 +50,9 @@ class DroptargetEntity extends Entity {
|
|
|
58
50
|
/**
|
|
59
51
|
* Sets the collision method which is going to be used to check a valid drop
|
|
60
52
|
* @name setCheckMethod
|
|
61
|
-
* @
|
|
53
|
+
* @memberof me.DroptargetEntity
|
|
62
54
|
* @function
|
|
63
|
-
* @param {
|
|
55
|
+
* @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
|
|
64
56
|
*/
|
|
65
57
|
setCheckMethod(checkMethod) {
|
|
66
58
|
// We can improve this check,
|
|
@@ -73,9 +65,10 @@ class DroptargetEntity extends Entity {
|
|
|
73
65
|
/**
|
|
74
66
|
* Checks if a dropped entity is dropped on the current entity
|
|
75
67
|
* @name checkOnMe
|
|
76
|
-
* @
|
|
68
|
+
* @memberof me.DroptargetEntity
|
|
77
69
|
* @function
|
|
78
|
-
* @param {
|
|
70
|
+
* @param {object} e the triggering event
|
|
71
|
+
* @param {object} draggableEntity the draggable entity that is dropped
|
|
79
72
|
*/
|
|
80
73
|
checkOnMe(e, draggableEntity) {
|
|
81
74
|
if (draggableEntity && this.checkMethod(draggableEntity.getBounds())) {
|
|
@@ -87,9 +80,9 @@ class DroptargetEntity extends Entity {
|
|
|
87
80
|
/**
|
|
88
81
|
* Gets called when a draggable entity is dropped on the current entity
|
|
89
82
|
* @name drop
|
|
90
|
-
* @
|
|
83
|
+
* @memberof me.DroptargetEntity
|
|
91
84
|
* @function
|
|
92
|
-
* @param {
|
|
85
|
+
* @param {object} draggableEntity the draggable entity that is dropped
|
|
93
86
|
*/
|
|
94
87
|
drop() {
|
|
95
88
|
|
|
@@ -98,7 +91,7 @@ class DroptargetEntity extends Entity {
|
|
|
98
91
|
/**
|
|
99
92
|
* Destructor
|
|
100
93
|
* @name destroy
|
|
101
|
-
* @
|
|
94
|
+
* @memberof me.DroptargetEntity
|
|
102
95
|
* @function
|
|
103
96
|
*/
|
|
104
97
|
destroy() {
|
package/src/entity/entity.js
CHANGED
|
@@ -2,30 +2,30 @@ import Vector2d from "./../math/vector2.js";
|
|
|
2
2
|
import Renderable from "./../renderable/renderable.js";
|
|
3
3
|
import Sprite from "./../renderable/sprite.js";
|
|
4
4
|
import Body from "./../physics/body.js";
|
|
5
|
-
import Polygon from "./../
|
|
5
|
+
import Polygon from "./../geometries/poly.js";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* @classdesc
|
|
9
10
|
* a Generic Object Entity
|
|
10
11
|
* @class Entity
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
12
|
+
* @augments me.Renderable
|
|
13
|
+
* @memberof me
|
|
13
14
|
* @see me.Renderable
|
|
14
|
-
* @
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {Object} settings Entity properties, to be defined through Tiled or when calling the entity constructor
|
|
15
|
+
* @param {number} x the x coordinates of the entity object
|
|
16
|
+
* @param {number} y the y coordinates of the entity object
|
|
17
|
+
* @param {object} settings Entity properties, to be defined through Tiled or when calling the entity constructor
|
|
18
18
|
* <img src="images/object_properties.png"/>
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {Image|
|
|
19
|
+
* @param {number} settings.width the physical width the entity takes up in game
|
|
20
|
+
* @param {number} settings.height the physical height the entity takes up in game
|
|
21
|
+
* @param {string} [settings.name] object entity name
|
|
22
|
+
* @param {string} [settings.id] object unique IDs
|
|
23
|
+
* @param {Image|string} [settings.image] resource name of a spritesheet to use for the entity renderable component
|
|
24
24
|
* @param {me.Vector2d} [settings.anchorPoint=0.0] Entity anchor point
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
25
|
+
* @param {number} [settings.framewidth=settings.width] width of a single frame in the given spritesheet
|
|
26
|
+
* @param {number} [settings.frameheight=settings.width] height of a single frame in the given spritesheet
|
|
27
|
+
* @param {string} [settings.type] object type
|
|
28
|
+
* @param {number} [settings.collisionMask] Mask collision detection for this object
|
|
29
29
|
* @param {me.Rect[]|me.Polygon[]|me.Line[]|me.Ellipse[]} [settings.shapes] the initial list of collision shapes (usually populated through Tiled)
|
|
30
30
|
*/
|
|
31
31
|
|
|
@@ -74,18 +74,18 @@ class Entity extends Renderable {
|
|
|
74
74
|
/**
|
|
75
75
|
* object type (as defined in Tiled)
|
|
76
76
|
* @public
|
|
77
|
-
* @type
|
|
77
|
+
* @type {string}
|
|
78
78
|
* @name type
|
|
79
|
-
* @
|
|
79
|
+
* @memberof me.Entity
|
|
80
80
|
*/
|
|
81
81
|
this.type = settings.type || "";
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* object unique ID (as defined in Tiled)
|
|
85
85
|
* @public
|
|
86
|
-
* @type
|
|
86
|
+
* @type {number}
|
|
87
87
|
* @name id
|
|
88
|
-
* @
|
|
88
|
+
* @memberof me.Entity
|
|
89
89
|
*/
|
|
90
90
|
this.id = settings.id || "";
|
|
91
91
|
|
|
@@ -93,18 +93,18 @@ class Entity extends Renderable {
|
|
|
93
93
|
* dead/living state of the entity<br>
|
|
94
94
|
* default value : true
|
|
95
95
|
* @public
|
|
96
|
-
* @type
|
|
96
|
+
* @type {boolean}
|
|
97
97
|
* @name alive
|
|
98
|
-
* @
|
|
98
|
+
* @memberof me.Entity
|
|
99
99
|
*/
|
|
100
100
|
this.alive = true;
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* the entity body object
|
|
104
104
|
* @public
|
|
105
|
-
* @type me.Body
|
|
105
|
+
* @type {me.Body}
|
|
106
106
|
* @name body
|
|
107
|
-
* @
|
|
107
|
+
* @memberof me.Entity
|
|
108
108
|
*/
|
|
109
109
|
// initialize the default body
|
|
110
110
|
if (typeof settings.shapes === "undefined") {
|
|
@@ -134,20 +134,15 @@ class Entity extends Renderable {
|
|
|
134
134
|
/**
|
|
135
135
|
* The entity renderable component (can be any objects deriving from me.Renderable, like me.Sprite for example)
|
|
136
136
|
* @public
|
|
137
|
-
* @type me.Renderable
|
|
137
|
+
* @type {me.Renderable}
|
|
138
138
|
* @name renderable
|
|
139
|
-
* @
|
|
139
|
+
* @memberof me.Entity
|
|
140
140
|
*/
|
|
141
141
|
|
|
142
|
-
/**
|
|
143
|
-
* @ignore
|
|
144
|
-
*/
|
|
145
142
|
get renderable() {
|
|
146
143
|
return this.children[0];
|
|
147
144
|
}
|
|
148
|
-
|
|
149
|
-
* @ignore
|
|
150
|
-
*/
|
|
145
|
+
|
|
151
146
|
set renderable(value) {
|
|
152
147
|
if (value instanceof Renderable) {
|
|
153
148
|
this.children[0] = value;
|
|
@@ -167,10 +162,11 @@ class Entity extends Renderable {
|
|
|
167
162
|
|
|
168
163
|
/**
|
|
169
164
|
* update the bounds position when the body is modified
|
|
170
|
-
* @
|
|
165
|
+
* @ignore
|
|
171
166
|
* @name onBodyUpdate
|
|
172
|
-
* @
|
|
167
|
+
* @memberof me.Entity
|
|
173
168
|
* @function
|
|
169
|
+
* @param {me.Body} body the body whose bounds to update
|
|
174
170
|
*/
|
|
175
171
|
onBodyUpdate(body) {
|
|
176
172
|
// update the entity bounds to include the body bounds
|
|
@@ -204,12 +200,12 @@ class Entity extends Renderable {
|
|
|
204
200
|
* not to be called by the end user<br>
|
|
205
201
|
* called by the game manager on each game loop
|
|
206
202
|
* @name draw
|
|
207
|
-
* @
|
|
203
|
+
* @memberof me.Entity
|
|
208
204
|
* @function
|
|
209
205
|
* @protected
|
|
210
206
|
* @param {me.CanvasRenderer|me.WebGLRenderer} renderer a renderer object
|
|
211
|
-
* @param {me.Rect} region to draw
|
|
212
|
-
|
|
207
|
+
* @param {me.Rect} rect region to draw
|
|
208
|
+
*/
|
|
213
209
|
draw(renderer, rect) {
|
|
214
210
|
var renderable = this.renderable;
|
|
215
211
|
if (renderable instanceof Renderable) {
|
|
@@ -243,7 +239,7 @@ class Entity extends Renderable {
|
|
|
243
239
|
* onDeactivateEvent Notification function<br>
|
|
244
240
|
* Called by engine before deleting the object
|
|
245
241
|
* @name onDeactivateEvent
|
|
246
|
-
* @
|
|
242
|
+
* @memberof me.Entity
|
|
247
243
|
* @function
|
|
248
244
|
*/
|
|
249
245
|
onDeactivateEvent() {
|
package/src/game.js
CHANGED
|
@@ -9,7 +9,7 @@ import World from "./physics/world.js";
|
|
|
9
9
|
* tilemap layers, current viewport, collision map, etc...<br>
|
|
10
10
|
* me.game is also responsible for updating (each frame) the object status and draw them.
|
|
11
11
|
* @namespace me.game
|
|
12
|
-
* @
|
|
12
|
+
* @memberof me
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
// to know when we have to refresh the display
|
|
@@ -49,7 +49,7 @@ event.on(event.BOOT, () => {
|
|
|
49
49
|
* @public
|
|
50
50
|
* @type {me.Camera2d}
|
|
51
51
|
* @name viewport
|
|
52
|
-
* @
|
|
52
|
+
* @memberof me.game
|
|
53
53
|
*/
|
|
54
54
|
export let viewport;
|
|
55
55
|
|
|
@@ -59,7 +59,7 @@ export let viewport;
|
|
|
59
59
|
* @public
|
|
60
60
|
* @type {me.World}
|
|
61
61
|
* @name world
|
|
62
|
-
* @
|
|
62
|
+
* @memberof me.game
|
|
63
63
|
*/
|
|
64
64
|
export let world;
|
|
65
65
|
|
|
@@ -70,7 +70,7 @@ export let world;
|
|
|
70
70
|
* @type {boolean}
|
|
71
71
|
* @default true
|
|
72
72
|
* @name mergeGroup
|
|
73
|
-
* @
|
|
73
|
+
* @memberof me.game
|
|
74
74
|
*/
|
|
75
75
|
export let mergeGroup = true;
|
|
76
76
|
|
|
@@ -81,7 +81,7 @@ export let mergeGroup = true;
|
|
|
81
81
|
* @type {string}
|
|
82
82
|
* @default "z"
|
|
83
83
|
* @name sortOn
|
|
84
|
-
* @
|
|
84
|
+
* @memberof me.game
|
|
85
85
|
*/
|
|
86
86
|
export let sortOn = "z";
|
|
87
87
|
|
|
@@ -93,7 +93,7 @@ export let sortOn = "z";
|
|
|
93
93
|
* @public
|
|
94
94
|
* @type {DOMHighResTimeStamp}
|
|
95
95
|
* @name lastUpdate
|
|
96
|
-
* @
|
|
96
|
+
* @memberof me.game
|
|
97
97
|
*/
|
|
98
98
|
export let lastUpdate = window.performance.now();
|
|
99
99
|
|
|
@@ -151,7 +151,7 @@ export function updateFrameRate() {
|
|
|
151
151
|
* Returns the parent container of the specified Child in the game world
|
|
152
152
|
* @function me.game.getParentContainer
|
|
153
153
|
* @param {me.Renderable} child
|
|
154
|
-
* @
|
|
154
|
+
* @returns {me.Container}
|
|
155
155
|
*/
|
|
156
156
|
export function getParentContainer(child) {
|
|
157
157
|
return child.ancestor;
|
|
@@ -170,7 +170,7 @@ export function repaint() {
|
|
|
170
170
|
* update all objects of the game manager
|
|
171
171
|
* @ignore
|
|
172
172
|
* @function me.game.update
|
|
173
|
-
* @param {
|
|
173
|
+
* @param {number} time current timestamp as provided by the RAF callback
|
|
174
174
|
* @param {me.Stage} stage the current stage
|
|
175
175
|
*/
|
|
176
176
|
export function update(time, stage) {
|
|
@@ -5,13 +5,12 @@ import pool from "./../system/pooling.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* an ellipse Object
|
|
7
7
|
* @class Ellipse
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {Number} h height (diameter) of the ellipse
|
|
8
|
+
* @augments me.Object
|
|
9
|
+
* @memberof me
|
|
10
|
+
* @param {number} x the center x coordinate of the ellipse
|
|
11
|
+
* @param {number} y the center y coordinate of the ellipse
|
|
12
|
+
* @param {number} w width (diameter) of the ellipse
|
|
13
|
+
* @param {number} h height (diameter) of the ellipse
|
|
15
14
|
*/
|
|
16
15
|
|
|
17
16
|
class Ellipse {
|
|
@@ -22,7 +21,7 @@ class Ellipse {
|
|
|
22
21
|
* @public
|
|
23
22
|
* @type {me.Vector2d}
|
|
24
23
|
* @name pos
|
|
25
|
-
* @
|
|
24
|
+
* @memberof me.Ellipse#
|
|
26
25
|
*/
|
|
27
26
|
this.pos = new Vector2d();
|
|
28
27
|
|
|
@@ -31,16 +30,16 @@ class Ellipse {
|
|
|
31
30
|
* @private
|
|
32
31
|
* @type {me.Bounds}
|
|
33
32
|
* @name _bounds
|
|
34
|
-
* @
|
|
33
|
+
* @memberof me.Ellipse#
|
|
35
34
|
*/
|
|
36
35
|
this._bounds = undefined;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* Maximum radius of the ellipse
|
|
40
39
|
* @public
|
|
41
|
-
* @type {
|
|
40
|
+
* @type {number}
|
|
42
41
|
* @name radius
|
|
43
|
-
* @
|
|
42
|
+
* @memberof me.Ellipse
|
|
44
43
|
*/
|
|
45
44
|
this.radius = NaN;
|
|
46
45
|
|
|
@@ -49,7 +48,7 @@ class Ellipse {
|
|
|
49
48
|
* @public
|
|
50
49
|
* @type {me.Vector2d}
|
|
51
50
|
* @name radiusV
|
|
52
|
-
* @
|
|
51
|
+
* @memberof me.Ellipse#
|
|
53
52
|
*/
|
|
54
53
|
this.radiusV = new Vector2d();
|
|
55
54
|
|
|
@@ -58,7 +57,7 @@ class Ellipse {
|
|
|
58
57
|
* @public
|
|
59
58
|
* @type {me.Vector2d}
|
|
60
59
|
* @name radiusSq
|
|
61
|
-
* @
|
|
60
|
+
* @memberof me.Ellipse#
|
|
62
61
|
*/
|
|
63
62
|
this.radiusSq = new Vector2d();
|
|
64
63
|
|
|
@@ -67,7 +66,7 @@ class Ellipse {
|
|
|
67
66
|
* @public
|
|
68
67
|
* @type {me.Vector2d}
|
|
69
68
|
* @name ratio
|
|
70
|
-
* @
|
|
69
|
+
* @memberof me.Ellipse#
|
|
71
70
|
*/
|
|
72
71
|
this.ratio = new Vector2d();
|
|
73
72
|
|
|
@@ -84,12 +83,13 @@ class Ellipse {
|
|
|
84
83
|
/**
|
|
85
84
|
* set new value to the Ellipse shape
|
|
86
85
|
* @name setShape
|
|
87
|
-
* @
|
|
86
|
+
* @memberof me.Ellipse.prototype
|
|
88
87
|
* @function
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
88
|
+
* @param {number} x the center x coordinate of the ellipse
|
|
89
|
+
* @param {number} y the center y coordinate of the ellipse
|
|
90
|
+
* @param {number} w width (diameter) of the ellipse
|
|
91
|
+
* @param {number} h height (diameter) of the ellipse
|
|
92
|
+
* @returns {me.Ellipse} this instance for objecf chaining
|
|
93
93
|
*/
|
|
94
94
|
setShape(x, y, w, h) {
|
|
95
95
|
var hW = w / 2;
|
|
@@ -113,11 +113,11 @@ class Ellipse {
|
|
|
113
113
|
/**
|
|
114
114
|
* Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
|
|
115
115
|
* @name rotate
|
|
116
|
-
* @
|
|
116
|
+
* @memberof me.Ellipse.prototype
|
|
117
117
|
* @function
|
|
118
|
-
* @param {
|
|
118
|
+
* @param {number} angle The angle to rotate (in radians)
|
|
119
119
|
* @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
|
|
120
|
-
* @
|
|
120
|
+
* @returns {me.Ellipse} Reference to this object for method chaining
|
|
121
121
|
*/
|
|
122
122
|
rotate(angle, v) {
|
|
123
123
|
// TODO : only works for circle
|
|
@@ -130,11 +130,11 @@ class Ellipse {
|
|
|
130
130
|
/**
|
|
131
131
|
* Scale this Ellipse by the specified scalar.
|
|
132
132
|
* @name scale
|
|
133
|
-
* @
|
|
133
|
+
* @memberof me.Ellipse.prototype
|
|
134
134
|
* @function
|
|
135
|
-
* @param {
|
|
136
|
-
* @param {
|
|
137
|
-
* @
|
|
135
|
+
* @param {number} x
|
|
136
|
+
* @param {number} [y=x]
|
|
137
|
+
* @returns {me.Ellipse} Reference to this object for method chaining
|
|
138
138
|
*/
|
|
139
139
|
scale(x, y) {
|
|
140
140
|
y = typeof (y) !== "undefined" ? y : x;
|
|
@@ -149,10 +149,10 @@ class Ellipse {
|
|
|
149
149
|
/**
|
|
150
150
|
* Scale this Ellipse by the specified vector.
|
|
151
151
|
* @name scale
|
|
152
|
-
* @
|
|
152
|
+
* @memberof me.Ellipse.prototype
|
|
153
153
|
* @function
|
|
154
154
|
* @param {me.Vector2d} v
|
|
155
|
-
* @
|
|
155
|
+
* @returns {me.Ellipse} Reference to this object for method chaining
|
|
156
156
|
*/
|
|
157
157
|
scaleV(v) {
|
|
158
158
|
return this.scale(v.x, v.y);
|
|
@@ -161,10 +161,10 @@ class Ellipse {
|
|
|
161
161
|
/**
|
|
162
162
|
* apply the given transformation matrix to this ellipse
|
|
163
163
|
* @name transform
|
|
164
|
-
* @
|
|
164
|
+
* @memberof me.Ellipse.prototype
|
|
165
165
|
* @function
|
|
166
166
|
* @param {me.Matrix2d} matrix the transformation matrix
|
|
167
|
-
* @
|
|
167
|
+
* @returns {me.Polygon} Reference to this object for method chaining
|
|
168
168
|
*/
|
|
169
169
|
transform(/* m */) {
|
|
170
170
|
// TODO
|
|
@@ -174,19 +174,19 @@ class Ellipse {
|
|
|
174
174
|
/**
|
|
175
175
|
* translate the circle/ellipse by the specified offset
|
|
176
176
|
* @name translate
|
|
177
|
-
* @
|
|
177
|
+
* @memberof me.Ellipse.prototype
|
|
178
178
|
* @function
|
|
179
|
-
* @param {
|
|
180
|
-
* @param {
|
|
181
|
-
* @
|
|
179
|
+
* @param {number} x x offset
|
|
180
|
+
* @param {number} y y offset
|
|
181
|
+
* @returns {me.Ellipse} this ellipse
|
|
182
182
|
*/
|
|
183
183
|
/**
|
|
184
184
|
* translate the circle/ellipse by the specified vector
|
|
185
185
|
* @name translate
|
|
186
|
-
* @
|
|
186
|
+
* @memberof me.Ellipse.prototype
|
|
187
187
|
* @function
|
|
188
188
|
* @param {me.Vector2d} v vector offset
|
|
189
|
-
* @
|
|
189
|
+
* @returns {me.Ellipse} this ellipse
|
|
190
190
|
*/
|
|
191
191
|
translate() {
|
|
192
192
|
var _x, _y;
|
|
@@ -211,20 +211,20 @@ class Ellipse {
|
|
|
211
211
|
/**
|
|
212
212
|
* check if this circle/ellipse contains the specified point
|
|
213
213
|
* @name contains
|
|
214
|
-
* @
|
|
214
|
+
* @memberof me.Ellipse.prototype
|
|
215
215
|
* @function
|
|
216
216
|
* @param {me.Vector2d} point
|
|
217
|
-
* @
|
|
217
|
+
* @returns {boolean} true if contains
|
|
218
218
|
*/
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
221
|
* check if this circle/ellipse contains the specified point
|
|
222
222
|
* @name contains
|
|
223
|
-
* @
|
|
223
|
+
* @memberof me.Ellipse.prototype
|
|
224
224
|
* @function
|
|
225
|
-
* @param {
|
|
226
|
-
* @param {
|
|
227
|
-
* @
|
|
225
|
+
* @param {number} x x coordinate
|
|
226
|
+
* @param {number} y y coordinate
|
|
227
|
+
* @returns {boolean} true if contains
|
|
228
228
|
*/
|
|
229
229
|
contains() {
|
|
230
230
|
var _x, _y;
|
|
@@ -252,9 +252,9 @@ class Ellipse {
|
|
|
252
252
|
/**
|
|
253
253
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
254
254
|
* @name getBounds
|
|
255
|
-
* @
|
|
255
|
+
* @memberof me.Ellipse.prototype
|
|
256
256
|
* @function
|
|
257
|
-
* @
|
|
257
|
+
* @returns {me.Bounds} this shape bounding box Rectangle object
|
|
258
258
|
*/
|
|
259
259
|
getBounds() {
|
|
260
260
|
if (typeof this._bounds === "undefined") {
|
|
@@ -266,9 +266,9 @@ class Ellipse {
|
|
|
266
266
|
/**
|
|
267
267
|
* clone this Ellipse
|
|
268
268
|
* @name clone
|
|
269
|
-
* @
|
|
269
|
+
* @memberof me.Ellipse.prototype
|
|
270
270
|
* @function
|
|
271
|
-
* @
|
|
271
|
+
* @returns {me.Ellipse} new Ellipse
|
|
272
272
|
*/
|
|
273
273
|
clone() {
|
|
274
274
|
return new Ellipse(
|