melonjs 10.2.3 → 10.5.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 +6 -6
- package/dist/melonjs.js +3620 -3582
- package/dist/melonjs.min.js +5 -5
- package/dist/melonjs.module.d.ts +3646 -4545
- package/dist/melonjs.module.js +3912 -3521
- package/package.json +21 -20
- package/src/audio/audio.js +30 -31
- package/src/camera/camera2d.js +47 -58
- package/src/entity/entity.js +32 -38
- package/src/game.js +21 -22
- package/src/{shapes → geometries}/ellipse.js +40 -47
- package/src/{shapes → geometries}/line.js +9 -12
- package/src/{shapes → geometries}/poly.js +100 -53
- package/src/{shapes → geometries}/rectangle.js +42 -45
- package/src/index.js +14 -32
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +61 -29
- package/src/input/pointerevent.js +92 -29
- package/src/lang/deprecated.js +83 -13
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -9
- package/src/level/tiled/TMXLayer.js +30 -33
- package/src/level/tiled/TMXObject.js +59 -53
- package/src/level/tiled/TMXTile.js +18 -19
- package/src/level/tiled/TMXTileMap.js +40 -46
- package/src/level/tiled/TMXTileset.js +12 -16
- package/src/level/tiled/TMXTilesetGroup.js +9 -10
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
- package/src/level/tiled/renderer/TMXRenderer.js +24 -26
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
- package/src/loader/loader.js +17 -16
- package/src/loader/loadingscreen.js +2 -5
- package/src/math/color.js +47 -67
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -59
- package/src/math/matrix3.js +56 -63
- package/src/math/observable_vector2.js +87 -77
- package/src/math/observable_vector3.js +97 -80
- package/src/math/vector2.js +107 -97
- package/src/math/vector3.js +116 -100
- package/src/particles/emitter.js +66 -76
- package/src/particles/particle.js +4 -6
- package/src/particles/particlecontainer.js +2 -4
- package/src/physics/body.js +49 -147
- package/src/physics/bounds.js +48 -50
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +18 -17
- package/src/physics/quadtree.js +17 -20
- package/src/physics/sat.js +30 -30
- package/src/physics/world.js +24 -29
- package/src/plugin/plugin.js +11 -15
- package/src/renderable/GUI.js +41 -47
- package/src/renderable/collectable.js +5 -10
- package/src/renderable/colorlayer.js +10 -15
- package/src/renderable/container.js +87 -73
- package/src/renderable/dragndrop.js +224 -0
- package/src/renderable/imagelayer.js +25 -32
- package/src/renderable/nineslicesprite.js +41 -42
- package/src/renderable/renderable.js +113 -124
- package/src/renderable/sprite.js +62 -69
- package/src/renderable/trigger.js +26 -32
- package/src/state/stage.js +13 -18
- package/src/state/state.js +26 -27
- package/src/system/device.js +76 -133
- package/src/system/event.js +81 -70
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -55
- package/src/text/bitmaptextdata.js +10 -11
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +49 -55
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +44 -46
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +60 -62
- package/src/video/renderer.js +53 -58
- package/src/video/texture.js +98 -112
- package/src/video/texture_cache.js +26 -10
- package/src/video/video.js +15 -16
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/glshader.js +37 -39
- package/src/video/webgl/webgl_compositor.js +128 -101
- package/src/video/webgl/webgl_renderer.js +126 -106
- package/src/entity/draggable.js +0 -139
- package/src/entity/droptarget.js +0 -109
package/src/entity/entity.js
CHANGED
|
@@ -2,38 +2,32 @@ 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
|
-
* @
|
|
12
|
-
* @memberOf me
|
|
13
|
-
* @see me.Renderable
|
|
14
|
-
* @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
|
-
* <img src="images/object_properties.png"/>
|
|
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
|
-
* @param {me.Vector2d} [settings.anchorPoint=0.0] Entity anchor point
|
|
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
|
-
* @param {me.Rect[]|me.Polygon[]|me.Line[]|me.Ellipse[]} [settings.shapes] the initial list of collision shapes (usually populated through Tiled)
|
|
11
|
+
* @augments Renderable
|
|
12
|
+
* @see Renderable
|
|
30
13
|
*/
|
|
31
|
-
|
|
32
14
|
class Entity extends Renderable {
|
|
33
|
-
|
|
34
|
-
|
|
35
15
|
/**
|
|
36
|
-
* @
|
|
16
|
+
* @param {number} x the x coordinates of the entity object
|
|
17
|
+
* @param {number} y the y coordinates of the entity object
|
|
18
|
+
* @param {object} settings Entity properties, to be defined through Tiled or when calling the entity constructor
|
|
19
|
+
* <img src="images/object_properties.png"/>
|
|
20
|
+
* @param {number} settings.width the physical width the entity takes up in game
|
|
21
|
+
* @param {number} settings.height the physical height the entity takes up in game
|
|
22
|
+
* @param {string} [settings.name] object entity name
|
|
23
|
+
* @param {string} [settings.id] object unique IDs
|
|
24
|
+
* @param {Image|string} [settings.image] resource name of a spritesheet to use for the entity renderable component
|
|
25
|
+
* @param {Vector2d} [settings.anchorPoint=0.0] Entity anchor point
|
|
26
|
+
* @param {number} [settings.framewidth=settings.width] width of a single frame in the given spritesheet
|
|
27
|
+
* @param {number} [settings.frameheight=settings.width] height of a single frame in the given spritesheet
|
|
28
|
+
* @param {string} [settings.type] object type
|
|
29
|
+
* @param {number} [settings.collisionMask] Mask collision detection for this object
|
|
30
|
+
* @param {Rect[]|Polygon[]|Line[]|Ellipse[]} [settings.shapes] the initial list of collision shapes (usually populated through Tiled)
|
|
37
31
|
*/
|
|
38
32
|
constructor(x, y, settings) {
|
|
39
33
|
|
|
@@ -76,7 +70,7 @@ class Entity extends Renderable {
|
|
|
76
70
|
* @public
|
|
77
71
|
* @type {string}
|
|
78
72
|
* @name type
|
|
79
|
-
* @
|
|
73
|
+
* @memberof Entity
|
|
80
74
|
*/
|
|
81
75
|
this.type = settings.type || "";
|
|
82
76
|
|
|
@@ -85,7 +79,7 @@ class Entity extends Renderable {
|
|
|
85
79
|
* @public
|
|
86
80
|
* @type {number}
|
|
87
81
|
* @name id
|
|
88
|
-
* @
|
|
82
|
+
* @memberof Entity
|
|
89
83
|
*/
|
|
90
84
|
this.id = settings.id || "";
|
|
91
85
|
|
|
@@ -95,16 +89,16 @@ class Entity extends Renderable {
|
|
|
95
89
|
* @public
|
|
96
90
|
* @type {boolean}
|
|
97
91
|
* @name alive
|
|
98
|
-
* @
|
|
92
|
+
* @memberof Entity
|
|
99
93
|
*/
|
|
100
94
|
this.alive = true;
|
|
101
95
|
|
|
102
96
|
/**
|
|
103
97
|
* the entity body object
|
|
104
98
|
* @public
|
|
105
|
-
* @type {
|
|
99
|
+
* @type {Body}
|
|
106
100
|
* @name body
|
|
107
|
-
* @
|
|
101
|
+
* @memberof Entity
|
|
108
102
|
*/
|
|
109
103
|
// initialize the default body
|
|
110
104
|
if (typeof settings.shapes === "undefined") {
|
|
@@ -134,9 +128,9 @@ class Entity extends Renderable {
|
|
|
134
128
|
/**
|
|
135
129
|
* The entity renderable component (can be any objects deriving from me.Renderable, like me.Sprite for example)
|
|
136
130
|
* @public
|
|
137
|
-
* @type {
|
|
131
|
+
* @type {Renderable}
|
|
138
132
|
* @name renderable
|
|
139
|
-
* @
|
|
133
|
+
* @memberof Entity
|
|
140
134
|
*/
|
|
141
135
|
|
|
142
136
|
get renderable() {
|
|
@@ -164,9 +158,9 @@ class Entity extends Renderable {
|
|
|
164
158
|
* update the bounds position when the body is modified
|
|
165
159
|
* @ignore
|
|
166
160
|
* @name onBodyUpdate
|
|
167
|
-
* @
|
|
161
|
+
* @memberof Entity
|
|
168
162
|
* @function
|
|
169
|
-
* @param {
|
|
163
|
+
* @param {Body} body the body whose bounds to update
|
|
170
164
|
*/
|
|
171
165
|
onBodyUpdate(body) {
|
|
172
166
|
// update the entity bounds to include the body bounds
|
|
@@ -200,11 +194,11 @@ class Entity extends Renderable {
|
|
|
200
194
|
* not to be called by the end user<br>
|
|
201
195
|
* called by the game manager on each game loop
|
|
202
196
|
* @name draw
|
|
203
|
-
* @
|
|
197
|
+
* @memberof Entity
|
|
204
198
|
* @function
|
|
205
199
|
* @protected
|
|
206
|
-
* @param {
|
|
207
|
-
* @param {
|
|
200
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
201
|
+
* @param {Rect} rect region to draw
|
|
208
202
|
*/
|
|
209
203
|
draw(renderer, rect) {
|
|
210
204
|
var renderable = this.renderable;
|
|
@@ -239,7 +233,7 @@ class Entity extends Renderable {
|
|
|
239
233
|
* onDeactivateEvent Notification function<br>
|
|
240
234
|
* Called by engine before deleting the object
|
|
241
235
|
* @name onDeactivateEvent
|
|
242
|
-
* @
|
|
236
|
+
* @memberof Entity
|
|
243
237
|
* @function
|
|
244
238
|
*/
|
|
245
239
|
onDeactivateEvent() {
|
package/src/game.js
CHANGED
|
@@ -8,8 +8,7 @@ import World from "./physics/world.js";
|
|
|
8
8
|
* me.game represents your current game, it contains all the objects,
|
|
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
|
-
* @namespace
|
|
12
|
-
* @memberOf me
|
|
11
|
+
* @namespace game
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
14
|
// to know when we have to refresh the display
|
|
@@ -47,9 +46,9 @@ event.on(event.BOOT, () => {
|
|
|
47
46
|
/**
|
|
48
47
|
* a reference to the current active stage "default" camera
|
|
49
48
|
* @public
|
|
50
|
-
* @type {
|
|
49
|
+
* @type {Camera2d}
|
|
51
50
|
* @name viewport
|
|
52
|
-
* @
|
|
51
|
+
* @memberof game
|
|
53
52
|
*/
|
|
54
53
|
export let viewport;
|
|
55
54
|
|
|
@@ -57,9 +56,9 @@ export let viewport;
|
|
|
57
56
|
* a reference to the game world, <br>
|
|
58
57
|
* a world is a virtual environment containing all the game objects
|
|
59
58
|
* @public
|
|
60
|
-
* @type {
|
|
59
|
+
* @type {World}
|
|
61
60
|
* @name world
|
|
62
|
-
* @
|
|
61
|
+
* @memberof game
|
|
63
62
|
*/
|
|
64
63
|
export let world;
|
|
65
64
|
|
|
@@ -70,7 +69,7 @@ export let world;
|
|
|
70
69
|
* @type {boolean}
|
|
71
70
|
* @default true
|
|
72
71
|
* @name mergeGroup
|
|
73
|
-
* @
|
|
72
|
+
* @memberof game
|
|
74
73
|
*/
|
|
75
74
|
export let mergeGroup = true;
|
|
76
75
|
|
|
@@ -81,7 +80,7 @@ export let mergeGroup = true;
|
|
|
81
80
|
* @type {string}
|
|
82
81
|
* @default "z"
|
|
83
82
|
* @name sortOn
|
|
84
|
-
* @
|
|
83
|
+
* @memberof game
|
|
85
84
|
*/
|
|
86
85
|
export let sortOn = "z";
|
|
87
86
|
|
|
@@ -93,14 +92,14 @@ export let sortOn = "z";
|
|
|
93
92
|
* @public
|
|
94
93
|
* @type {DOMHighResTimeStamp}
|
|
95
94
|
* @name lastUpdate
|
|
96
|
-
* @
|
|
95
|
+
* @memberof game
|
|
97
96
|
*/
|
|
98
97
|
export let lastUpdate = window.performance.now();
|
|
99
98
|
|
|
100
99
|
/**
|
|
101
100
|
* Fired when a level is fully loaded and all entities instantiated. <br>
|
|
102
101
|
* Additionnaly the level id will also be passed to the called function.
|
|
103
|
-
* @function
|
|
102
|
+
* @function game.onLevelLoaded
|
|
104
103
|
* @example
|
|
105
104
|
* // call myFunction () everytime a level is loaded
|
|
106
105
|
* me.game.onLevelLoaded = this.myFunction.bind(this);
|
|
@@ -110,7 +109,7 @@ export function onLevelLoaded() {};
|
|
|
110
109
|
/**
|
|
111
110
|
* reset the game Object manager<br>
|
|
112
111
|
* destroy all current objects
|
|
113
|
-
* @function
|
|
112
|
+
* @function game.reset
|
|
114
113
|
*/
|
|
115
114
|
export function reset () {
|
|
116
115
|
// point to the current active stage "default" camera
|
|
@@ -128,9 +127,9 @@ export function reset () {
|
|
|
128
127
|
|
|
129
128
|
/**
|
|
130
129
|
* Update the renderer framerate using the system config variables.
|
|
131
|
-
* @function
|
|
132
|
-
* @see
|
|
133
|
-
* @see
|
|
130
|
+
* @function game.updateFrameRate
|
|
131
|
+
* @see timer.maxfps
|
|
132
|
+
* @see World.fps
|
|
134
133
|
*/
|
|
135
134
|
export function updateFrameRate() {
|
|
136
135
|
// reset the frame counter
|
|
@@ -149,9 +148,9 @@ export function updateFrameRate() {
|
|
|
149
148
|
|
|
150
149
|
/**
|
|
151
150
|
* Returns the parent container of the specified Child in the game world
|
|
152
|
-
* @function
|
|
153
|
-
* @param {
|
|
154
|
-
* @returns {
|
|
151
|
+
* @function game.getParentContainer
|
|
152
|
+
* @param {Renderable} child
|
|
153
|
+
* @returns {Container}
|
|
155
154
|
*/
|
|
156
155
|
export function getParentContainer(child) {
|
|
157
156
|
return child.ancestor;
|
|
@@ -159,7 +158,7 @@ export function getParentContainer(child) {
|
|
|
159
158
|
|
|
160
159
|
/**
|
|
161
160
|
* force the redraw (not update) of all objects
|
|
162
|
-
* @function
|
|
161
|
+
* @function game.repaint
|
|
163
162
|
*/
|
|
164
163
|
export function repaint() {
|
|
165
164
|
isDirty = true;
|
|
@@ -169,9 +168,9 @@ export function repaint() {
|
|
|
169
168
|
/**
|
|
170
169
|
* update all objects of the game manager
|
|
171
170
|
* @ignore
|
|
172
|
-
* @function
|
|
171
|
+
* @function game.update
|
|
173
172
|
* @param {number} time current timestamp as provided by the RAF callback
|
|
174
|
-
* @param {
|
|
173
|
+
* @param {Stage} stage the current stage
|
|
175
174
|
*/
|
|
176
175
|
export function update(time, stage) {
|
|
177
176
|
// handle frame skipping if required
|
|
@@ -216,9 +215,9 @@ export function update(time, stage) {
|
|
|
216
215
|
|
|
217
216
|
/**
|
|
218
217
|
* draw the current scene/stage
|
|
219
|
-
* @function
|
|
218
|
+
* @function game.draw
|
|
220
219
|
* @ignore
|
|
221
|
-
* @param {
|
|
220
|
+
* @param {Stage} stage the current stage
|
|
222
221
|
*/
|
|
223
222
|
export function draw(stage) {
|
|
224
223
|
|
|
@@ -4,34 +4,27 @@ import pool from "./../system/pooling.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc
|
|
6
6
|
* an ellipse Object
|
|
7
|
-
* @class Ellipse
|
|
8
|
-
* @extends me.Object
|
|
9
|
-
* @memberOf me
|
|
10
|
-
* @constructor
|
|
11
|
-
* @param {number} x the center x coordinate of the ellipse
|
|
12
|
-
* @param {number} y the center y coordinate of the ellipse
|
|
13
|
-
* @param {number} w width (diameter) of the ellipse
|
|
14
|
-
* @param {number} h height (diameter) of the ellipse
|
|
15
7
|
*/
|
|
16
|
-
|
|
17
8
|
class Ellipse {
|
|
18
|
-
|
|
9
|
+
/**
|
|
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
|
|
14
|
+
*/
|
|
19
15
|
constructor(x, y, w, h) {
|
|
20
16
|
/**
|
|
21
17
|
* the center coordinates of the ellipse
|
|
22
18
|
* @public
|
|
23
|
-
* @type {
|
|
19
|
+
* @type {Vector2d}
|
|
24
20
|
* @name pos
|
|
25
|
-
* @
|
|
21
|
+
* @memberof Ellipse#
|
|
26
22
|
*/
|
|
27
23
|
this.pos = new Vector2d();
|
|
28
24
|
|
|
29
25
|
/**
|
|
30
26
|
* The bounding rectangle for this shape
|
|
31
27
|
* @private
|
|
32
|
-
* @type {me.Bounds}
|
|
33
|
-
* @name _bounds
|
|
34
|
-
* @memberOf me.Ellipse#
|
|
35
28
|
*/
|
|
36
29
|
this._bounds = undefined;
|
|
37
30
|
|
|
@@ -40,34 +33,34 @@ class Ellipse {
|
|
|
40
33
|
* @public
|
|
41
34
|
* @type {number}
|
|
42
35
|
* @name radius
|
|
43
|
-
* @
|
|
36
|
+
* @memberof Ellipse
|
|
44
37
|
*/
|
|
45
38
|
this.radius = NaN;
|
|
46
39
|
|
|
47
40
|
/**
|
|
48
41
|
* Pre-scaled radius vector for ellipse
|
|
49
42
|
* @public
|
|
50
|
-
* @type {
|
|
43
|
+
* @type {Vector2d}
|
|
51
44
|
* @name radiusV
|
|
52
|
-
* @
|
|
45
|
+
* @memberof Ellipse#
|
|
53
46
|
*/
|
|
54
47
|
this.radiusV = new Vector2d();
|
|
55
48
|
|
|
56
49
|
/**
|
|
57
50
|
* Radius squared, for pythagorean theorom
|
|
58
51
|
* @public
|
|
59
|
-
* @type {
|
|
52
|
+
* @type {Vector2d}
|
|
60
53
|
* @name radiusSq
|
|
61
|
-
* @
|
|
54
|
+
* @memberof Ellipse#
|
|
62
55
|
*/
|
|
63
56
|
this.radiusSq = new Vector2d();
|
|
64
57
|
|
|
65
58
|
/**
|
|
66
59
|
* x/y scaling ratio for ellipse
|
|
67
60
|
* @public
|
|
68
|
-
* @type {
|
|
61
|
+
* @type {Vector2d}
|
|
69
62
|
* @name ratio
|
|
70
|
-
* @
|
|
63
|
+
* @memberof Ellipse#
|
|
71
64
|
*/
|
|
72
65
|
this.ratio = new Vector2d();
|
|
73
66
|
|
|
@@ -84,13 +77,13 @@ class Ellipse {
|
|
|
84
77
|
/**
|
|
85
78
|
* set new value to the Ellipse shape
|
|
86
79
|
* @name setShape
|
|
87
|
-
* @
|
|
80
|
+
* @memberof Ellipse.prototype
|
|
88
81
|
* @function
|
|
89
82
|
* @param {number} x the center x coordinate of the ellipse
|
|
90
83
|
* @param {number} y the center y coordinate of the ellipse
|
|
91
84
|
* @param {number} w width (diameter) of the ellipse
|
|
92
85
|
* @param {number} h height (diameter) of the ellipse
|
|
93
|
-
* @returns {
|
|
86
|
+
* @returns {Ellipse} this instance for objecf chaining
|
|
94
87
|
*/
|
|
95
88
|
setShape(x, y, w, h) {
|
|
96
89
|
var hW = w / 2;
|
|
@@ -114,11 +107,11 @@ class Ellipse {
|
|
|
114
107
|
/**
|
|
115
108
|
* Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
|
|
116
109
|
* @name rotate
|
|
117
|
-
* @
|
|
110
|
+
* @memberof Ellipse.prototype
|
|
118
111
|
* @function
|
|
119
112
|
* @param {number} angle The angle to rotate (in radians)
|
|
120
|
-
* @param {
|
|
121
|
-
* @returns {
|
|
113
|
+
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
|
|
114
|
+
* @returns {Ellipse} Reference to this object for method chaining
|
|
122
115
|
*/
|
|
123
116
|
rotate(angle, v) {
|
|
124
117
|
// TODO : only works for circle
|
|
@@ -131,11 +124,11 @@ class Ellipse {
|
|
|
131
124
|
/**
|
|
132
125
|
* Scale this Ellipse by the specified scalar.
|
|
133
126
|
* @name scale
|
|
134
|
-
* @
|
|
127
|
+
* @memberof Ellipse.prototype
|
|
135
128
|
* @function
|
|
136
129
|
* @param {number} x
|
|
137
130
|
* @param {number} [y=x]
|
|
138
|
-
* @returns {
|
|
131
|
+
* @returns {Ellipse} Reference to this object for method chaining
|
|
139
132
|
*/
|
|
140
133
|
scale(x, y) {
|
|
141
134
|
y = typeof (y) !== "undefined" ? y : x;
|
|
@@ -150,10 +143,10 @@ class Ellipse {
|
|
|
150
143
|
/**
|
|
151
144
|
* Scale this Ellipse by the specified vector.
|
|
152
145
|
* @name scale
|
|
153
|
-
* @
|
|
146
|
+
* @memberof Ellipse.prototype
|
|
154
147
|
* @function
|
|
155
|
-
* @param {
|
|
156
|
-
* @returns {
|
|
148
|
+
* @param {Vector2d} v
|
|
149
|
+
* @returns {Ellipse} Reference to this object for method chaining
|
|
157
150
|
*/
|
|
158
151
|
scaleV(v) {
|
|
159
152
|
return this.scale(v.x, v.y);
|
|
@@ -162,10 +155,10 @@ class Ellipse {
|
|
|
162
155
|
/**
|
|
163
156
|
* apply the given transformation matrix to this ellipse
|
|
164
157
|
* @name transform
|
|
165
|
-
* @
|
|
158
|
+
* @memberof Ellipse.prototype
|
|
166
159
|
* @function
|
|
167
|
-
* @param {
|
|
168
|
-
* @returns {
|
|
160
|
+
* @param {Matrix2d} matrix the transformation matrix
|
|
161
|
+
* @returns {Polygon} Reference to this object for method chaining
|
|
169
162
|
*/
|
|
170
163
|
transform(/* m */) {
|
|
171
164
|
// TODO
|
|
@@ -175,19 +168,19 @@ class Ellipse {
|
|
|
175
168
|
/**
|
|
176
169
|
* translate the circle/ellipse by the specified offset
|
|
177
170
|
* @name translate
|
|
178
|
-
* @
|
|
171
|
+
* @memberof Ellipse.prototype
|
|
179
172
|
* @function
|
|
180
173
|
* @param {number} x x offset
|
|
181
174
|
* @param {number} y y offset
|
|
182
|
-
* @returns {
|
|
175
|
+
* @returns {Ellipse} this ellipse
|
|
183
176
|
*/
|
|
184
177
|
/**
|
|
185
178
|
* translate the circle/ellipse by the specified vector
|
|
186
179
|
* @name translate
|
|
187
|
-
* @
|
|
180
|
+
* @memberof Ellipse.prototype
|
|
188
181
|
* @function
|
|
189
|
-
* @param {
|
|
190
|
-
* @returns {
|
|
182
|
+
* @param {Vector2d} v vector offset
|
|
183
|
+
* @returns {Ellipse} this ellipse
|
|
191
184
|
*/
|
|
192
185
|
translate() {
|
|
193
186
|
var _x, _y;
|
|
@@ -212,16 +205,16 @@ class Ellipse {
|
|
|
212
205
|
/**
|
|
213
206
|
* check if this circle/ellipse contains the specified point
|
|
214
207
|
* @name contains
|
|
215
|
-
* @
|
|
208
|
+
* @memberof Ellipse.prototype
|
|
216
209
|
* @function
|
|
217
|
-
* @param
|
|
210
|
+
* @param {Vector2d} point
|
|
218
211
|
* @returns {boolean} true if contains
|
|
219
212
|
*/
|
|
220
213
|
|
|
221
214
|
/**
|
|
222
215
|
* check if this circle/ellipse contains the specified point
|
|
223
216
|
* @name contains
|
|
224
|
-
* @
|
|
217
|
+
* @memberof Ellipse.prototype
|
|
225
218
|
* @function
|
|
226
219
|
* @param {number} x x coordinate
|
|
227
220
|
* @param {number} y y coordinate
|
|
@@ -253,9 +246,9 @@ class Ellipse {
|
|
|
253
246
|
/**
|
|
254
247
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
255
248
|
* @name getBounds
|
|
256
|
-
* @
|
|
249
|
+
* @memberof Ellipse.prototype
|
|
257
250
|
* @function
|
|
258
|
-
* @returns {
|
|
251
|
+
* @returns {Bounds} this shape bounding box Rectangle object
|
|
259
252
|
*/
|
|
260
253
|
getBounds() {
|
|
261
254
|
if (typeof this._bounds === "undefined") {
|
|
@@ -267,9 +260,9 @@ class Ellipse {
|
|
|
267
260
|
/**
|
|
268
261
|
* clone this Ellipse
|
|
269
262
|
* @name clone
|
|
270
|
-
* @
|
|
263
|
+
* @memberof Ellipse.prototype
|
|
271
264
|
* @function
|
|
272
|
-
* @returns {
|
|
265
|
+
* @returns {Ellipse} new Ellipse
|
|
273
266
|
*/
|
|
274
267
|
clone() {
|
|
275
268
|
return new Ellipse(
|
|
@@ -4,13 +4,10 @@ import Polygon from "./poly.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a line segment Object
|
|
7
|
-
* @
|
|
8
|
-
* @extends me.Polygon
|
|
9
|
-
* @memberOf me
|
|
10
|
-
* @constructor
|
|
7
|
+
* @augments Polygon
|
|
11
8
|
* @param {number} x origin point of the Line
|
|
12
9
|
* @param {number} y origin point of the Line
|
|
13
|
-
* @param {
|
|
10
|
+
* @param {Vector2d[]} points array of vectors defining the Line
|
|
14
11
|
*/
|
|
15
12
|
|
|
16
13
|
class Line extends Polygon {
|
|
@@ -18,16 +15,16 @@ class Line extends Polygon {
|
|
|
18
15
|
/**
|
|
19
16
|
* Returns true if the Line contains the given point
|
|
20
17
|
* @name contains
|
|
21
|
-
* @
|
|
18
|
+
* @memberof Line.prototype
|
|
22
19
|
* @function
|
|
23
|
-
* @param
|
|
20
|
+
* @param {Vector2d} point
|
|
24
21
|
* @returns {boolean} true if contains
|
|
25
22
|
*/
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
25
|
* Returns true if the Line contains the given point
|
|
29
26
|
* @name contains
|
|
30
|
-
* @
|
|
27
|
+
* @memberof Line.prototype
|
|
31
28
|
* @function
|
|
32
29
|
* @param {number} x x coordinate
|
|
33
30
|
* @param {number} y y coordinate
|
|
@@ -61,9 +58,9 @@ class Line extends Polygon {
|
|
|
61
58
|
* Computes the calculated collision edges and normals.
|
|
62
59
|
* This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
|
|
63
60
|
* @name recalc
|
|
64
|
-
* @
|
|
61
|
+
* @memberof Line.prototype
|
|
65
62
|
* @function
|
|
66
|
-
* @returns {
|
|
63
|
+
* @returns {Line} this instance for objecf chaining
|
|
67
64
|
*/
|
|
68
65
|
recalc() {
|
|
69
66
|
var edges = this.edges;
|
|
@@ -97,9 +94,9 @@ class Line extends Polygon {
|
|
|
97
94
|
/**
|
|
98
95
|
* clone this line segment
|
|
99
96
|
* @name clone
|
|
100
|
-
* @
|
|
97
|
+
* @memberof Line.prototype
|
|
101
98
|
* @function
|
|
102
|
-
* @returns {
|
|
99
|
+
* @returns {Line} new Line
|
|
103
100
|
*/
|
|
104
101
|
clone() {
|
|
105
102
|
var copy = [];
|