melonjs 10.3.0 → 10.5.1

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.
Files changed (95) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +3147 -3293
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3411 -3852
  5. package/dist/melonjs.module.js +3448 -3210
  6. package/package.json +18 -17
  7. package/src/audio/audio.js +29 -30
  8. package/src/camera/camera2d.js +46 -56
  9. package/src/entity/entity.js +30 -36
  10. package/src/game.js +21 -22
  11. package/src/geometries/ellipse.js +40 -46
  12. package/src/geometries/line.js +9 -11
  13. package/src/geometries/poly.js +53 -53
  14. package/src/geometries/rectangle.js +42 -44
  15. package/src/index.js +9 -26
  16. package/src/input/gamepad.js +11 -10
  17. package/src/input/input.js +2 -3
  18. package/src/input/keyboard.js +113 -113
  19. package/src/input/pointer.js +30 -31
  20. package/src/input/pointerevent.js +26 -26
  21. package/src/lang/deprecated.js +65 -6
  22. package/src/level/level.js +23 -24
  23. package/src/level/tiled/TMXGroup.js +7 -8
  24. package/src/level/tiled/TMXLayer.js +30 -32
  25. package/src/level/tiled/TMXObject.js +21 -21
  26. package/src/level/tiled/TMXTile.js +18 -18
  27. package/src/level/tiled/TMXTileMap.js +39 -44
  28. package/src/level/tiled/TMXTileset.js +12 -15
  29. package/src/level/tiled/TMXTilesetGroup.js +9 -9
  30. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
  31. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
  32. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
  33. package/src/level/tiled/renderer/TMXRenderer.js +24 -25
  34. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
  35. package/src/loader/loader.js +14 -15
  36. package/src/loader/loadingscreen.js +2 -4
  37. package/src/math/color.js +47 -66
  38. package/src/math/math.js +15 -16
  39. package/src/math/matrix2.js +53 -58
  40. package/src/math/matrix3.js +56 -62
  41. package/src/math/observable_vector2.js +75 -76
  42. package/src/math/observable_vector3.js +79 -80
  43. package/src/math/vector2.js +91 -92
  44. package/src/math/vector3.js +94 -96
  45. package/src/particles/emitter.js +38 -40
  46. package/src/particles/particle.js +4 -5
  47. package/src/particles/particlecontainer.js +2 -3
  48. package/src/physics/body.js +46 -143
  49. package/src/physics/bounds.js +47 -47
  50. package/src/physics/collision.js +13 -14
  51. package/src/physics/detector.js +18 -17
  52. package/src/physics/quadtree.js +17 -19
  53. package/src/physics/sat.js +26 -26
  54. package/src/physics/world.js +24 -28
  55. package/src/plugin/plugin.js +11 -14
  56. package/src/renderable/GUI.js +41 -46
  57. package/src/renderable/collectable.js +4 -8
  58. package/src/renderable/colorlayer.js +6 -10
  59. package/src/renderable/container.js +87 -72
  60. package/src/renderable/dragndrop.js +224 -0
  61. package/src/renderable/imagelayer.js +25 -31
  62. package/src/renderable/nineslicesprite.js +41 -41
  63. package/src/renderable/renderable.js +114 -125
  64. package/src/renderable/sprite.js +62 -68
  65. package/src/renderable/trigger.js +25 -30
  66. package/src/state/stage.js +13 -17
  67. package/src/state/state.js +26 -27
  68. package/src/system/device.js +74 -75
  69. package/src/system/event.js +71 -72
  70. package/src/system/pooling.js +11 -12
  71. package/src/system/save.js +3 -4
  72. package/src/system/timer.js +19 -20
  73. package/src/text/bitmaptext.js +57 -54
  74. package/src/text/bitmaptextdata.js +10 -10
  75. package/src/text/glyph.js +3 -0
  76. package/src/text/text.js +44 -49
  77. package/src/tweens/easing.js +1 -1
  78. package/src/tweens/interpolation.js +1 -1
  79. package/src/tweens/tween.js +43 -44
  80. package/src/utils/agent.js +3 -4
  81. package/src/utils/array.js +4 -5
  82. package/src/utils/file.js +3 -4
  83. package/src/utils/function.js +4 -5
  84. package/src/utils/string.js +7 -9
  85. package/src/utils/utils.js +4 -5
  86. package/src/video/canvas/canvas_renderer.js +58 -59
  87. package/src/video/renderer.js +49 -53
  88. package/src/video/texture.js +98 -111
  89. package/src/video/texture_cache.js +24 -6
  90. package/src/video/video.js +16 -17
  91. package/src/video/webgl/glshader.js +37 -38
  92. package/src/video/webgl/webgl_compositor.js +31 -32
  93. package/src/video/webgl/webgl_renderer.js +79 -80
  94. package/src/entity/draggable.js +0 -130
  95. package/src/entity/droptarget.js +0 -101
@@ -4,7 +4,7 @@ import Matrix2d from "./../../math/matrix2.js";
4
4
  import WebGLCompositor from "./webgl_compositor.js";
5
5
  import Renderer from "./../renderer.js";
6
6
  import TextureCache from "./../texture_cache.js";
7
- import {Texture, createAtlas } from "./../texture.js";
7
+ import { TextureAtlas, createAtlas } from "./../texture.js";
8
8
  import { createCanvas, renderer } from "./../video.js";
9
9
  import * as event from "./../../system/event.js";
10
10
  import pool from "./../../system/pooling.js";
@@ -14,26 +14,25 @@ import { isPowerOfTwo, nextPowerOfTwo, TAU } from "./../../math/math.js";
14
14
  /**
15
15
  * @classdesc
16
16
  * a WebGL renderer object
17
- * @class WebGLRenderer
18
- * @augments me.Renderer
19
- * @memberof me
20
- * @param {object} options The renderer parameters
21
- * @param {number} options.width The width of the canvas without scaling
22
- * @param {number} options.height The height of the canvas without scaling
23
- * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
24
- * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
25
- * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
26
- * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
27
- * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
28
- * @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
29
- * @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
30
- * @param {string} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
31
- * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
32
- * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
33
- * @param {me.WebGLCompositor} [options.compositor] A class that implements the compositor API
17
+ * @augments Renderer
34
18
  */
35
19
  class WebGLRenderer extends Renderer {
36
-
20
+ /**
21
+ * @param {object} options The renderer parameters
22
+ * @param {number} options.width The width of the canvas without scaling
23
+ * @param {number} options.height The height of the canvas without scaling
24
+ * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
25
+ * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
26
+ * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
27
+ * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
28
+ * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
29
+ * @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
30
+ * @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
31
+ * @param {string} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
32
+ * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
33
+ * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
34
+ * @param {WebGLCompositor} [options.compositor] A class that implements the compositor API
35
+ */
37
36
  constructor(options) {
38
37
 
39
38
  // parent contructor
@@ -42,7 +41,7 @@ class WebGLRenderer extends Renderer {
42
41
  /**
43
42
  * The WebGL version used by this renderer (1 or 2)
44
43
  * @name WebGLVersion
45
- * @memberof me.WebGLRenderer
44
+ * @memberof WebGLRenderer
46
45
  * @type {number}
47
46
  * @default 1
48
47
  * @readonly
@@ -52,7 +51,7 @@ class WebGLRenderer extends Renderer {
52
51
  /**
53
52
  * The vendor string of the underlying graphics driver.
54
53
  * @name GPUVendor
55
- * @memberof me.WebGLRenderer
54
+ * @memberof WebGLRenderer
56
55
  * @type {string}
57
56
  * @default null
58
57
  * @readonly
@@ -62,7 +61,7 @@ class WebGLRenderer extends Renderer {
62
61
  /**
63
62
  * The renderer string of the underlying graphics driver.
64
63
  * @name GPURenderer
65
- * @memberof me.WebGLRenderer
64
+ * @memberof WebGLRenderer
66
65
  * @type {string}
67
66
  * @default null
68
67
  * @readonly
@@ -72,7 +71,7 @@ class WebGLRenderer extends Renderer {
72
71
  /**
73
72
  * The WebGL context
74
73
  * @name gl
75
- * @memberof me.WebGLRenderer
74
+ * @memberof WebGLRenderer
76
75
  * type {WebGLRenderingContext}
77
76
  */
78
77
  this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
@@ -80,7 +79,7 @@ class WebGLRenderer extends Renderer {
80
79
  /**
81
80
  * Maximum number of texture unit supported under the current context
82
81
  * @name maxTextures
83
- * @memberof me.WebGLRenderer
82
+ * @memberof WebGLRenderer
84
83
  * @type {number}
85
84
  * @readonly
86
85
  */
@@ -114,16 +113,16 @@ class WebGLRenderer extends Renderer {
114
113
  /**
115
114
  * The current transformation matrix used for transformations on the overall scene
116
115
  * @name currentTransform
117
- * @type {me.Matrix2d}
118
- * @memberof me.WebGLRenderer#
116
+ * @type {Matrix2d}
117
+ * @memberof WebGLRenderer#
119
118
  */
120
119
  this.currentTransform = new Matrix2d();
121
120
 
122
121
  /**
123
122
  * The current compositor used by the renderer
124
123
  * @name currentCompositor
125
- * @type {me.WebGLCompositor}
126
- * @memberof me.WebGLRenderer#
124
+ * @type {WebGLCompositor}
125
+ * @memberof WebGLRenderer#
127
126
  */
128
127
  this.currentCompositor = null;
129
128
 
@@ -131,7 +130,7 @@ class WebGLRenderer extends Renderer {
131
130
  * The list of active compositors
132
131
  * @name compositors
133
132
  * @type {Map}
134
- * @memberof me.WebGLRenderer#
133
+ * @memberof WebGLRenderer#
135
134
  */
136
135
  this.compositors = new Map();
137
136
 
@@ -180,7 +179,7 @@ class WebGLRenderer extends Renderer {
180
179
  /**
181
180
  * Reset context state
182
181
  * @name reset
183
- * @memberof me.WebGLRenderer.prototype
182
+ * @memberof WebGLRenderer.prototype
184
183
  * @function
185
184
  */
186
185
  reset() {
@@ -206,8 +205,8 @@ class WebGLRenderer extends Renderer {
206
205
  * set the active compositor for this renderer
207
206
  * @name setCompositor
208
207
  * @function
209
- * @param {me.WebGLCompositor|string} compositor a compositor name or instance
210
- * @memberof me.WebGLRenderer.prototype
208
+ * @param {WebGLCompositor|string} compositor a compositor name or instance
209
+ * @memberof WebGLRenderer.prototype
211
210
  * @function
212
211
  */
213
212
  setCompositor(compositor = "default") {
@@ -233,7 +232,7 @@ class WebGLRenderer extends Renderer {
233
232
  /**
234
233
  * Reset the gl transform to identity
235
234
  * @name resetTransform
236
- * @memberof me.WebGLRenderer.prototype
235
+ * @memberof WebGLRenderer.prototype
237
236
  * @function
238
237
  */
239
238
  resetTransform() {
@@ -268,7 +267,7 @@ class WebGLRenderer extends Renderer {
268
267
  /**
269
268
  * @ignore
270
269
  */
271
- this.fontTexture = new Texture(createAtlas(canvas.width, canvas.height, "fontTexture"), image, cache);
270
+ this.fontTexture = new TextureAtlas(createAtlas(canvas.width, canvas.height, "fontTexture"), image, cache);
272
271
  this.currentCompositor.uploadTexture(this.fontTexture, 0, 0, 0);
273
272
 
274
273
  } else {
@@ -280,12 +279,12 @@ class WebGLRenderer extends Renderer {
280
279
  /**
281
280
  * Create a pattern with the specified repetition
282
281
  * @name createPattern
283
- * @memberof me.WebGLRenderer.prototype
282
+ * @memberof WebGLRenderer.prototype
284
283
  * @function
285
284
  * @param {Image} image Source image
286
285
  * @param {string} repeat Define how the pattern should be repeated
287
- * @returns {me.Renderer.Texture}
288
- * @see me.ImageLayer#repeat
286
+ * @returns {TextureAtlas}
287
+ * @see ImageLayer#repeat
289
288
  * @example
290
289
  * var tileable = renderer.createPattern(image, "repeat");
291
290
  * var horizontal = renderer.createPattern(image, "repeat-x");
@@ -302,7 +301,7 @@ class WebGLRenderer extends Renderer {
302
301
  );
303
302
  }
304
303
 
305
- var texture = new Texture(createAtlas(image.width, image.height, "pattern", repeat), image);
304
+ var texture = new TextureAtlas(createAtlas(image.width, image.height, "pattern", repeat), image);
306
305
 
307
306
  // FIXME: Remove old cache entry and texture when changing the repeat mode
308
307
  this.currentCompositor.uploadTexture(texture);
@@ -313,7 +312,7 @@ class WebGLRenderer extends Renderer {
313
312
  /**
314
313
  * Flush the compositor to the frame buffer
315
314
  * @name flush
316
- * @memberof me.WebGLRenderer.prototype
315
+ * @memberof WebGLRenderer.prototype
317
316
  * @function
318
317
  */
319
318
  flush() {
@@ -323,9 +322,9 @@ class WebGLRenderer extends Renderer {
323
322
  /**
324
323
  * Clears the gl context with the given color.
325
324
  * @name clearColor
326
- * @memberof me.WebGLRenderer.prototype
325
+ * @memberof WebGLRenderer.prototype
327
326
  * @function
328
- * @param {me.Color|string} [color="#000000"] CSS color.
327
+ * @param {Color|string} [color="#000000"] CSS color.
329
328
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
330
329
  */
331
330
  clearColor(color = "#000000", opaque = false) {
@@ -351,7 +350,7 @@ class WebGLRenderer extends Renderer {
351
350
  /**
352
351
  * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
353
352
  * @name clearRect
354
- * @memberof me.WebGLRenderer.prototype
353
+ * @memberof WebGLRenderer.prototype
355
354
  * @function
356
355
  * @param {number} x x axis of the coordinate for the rectangle starting point.
357
356
  * @param {number} y y axis of the coordinate for the rectangle starting point.
@@ -401,7 +400,7 @@ class WebGLRenderer extends Renderer {
401
400
  /**
402
401
  * Draw an image to the gl context
403
402
  * @name drawImage
404
- * @memberof me.WebGLRenderer.prototype
403
+ * @memberof WebGLRenderer.prototype
405
404
  * @function
406
405
  * @param {Image} image An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
407
406
  * @param {number} sx The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
@@ -454,14 +453,14 @@ class WebGLRenderer extends Renderer {
454
453
  /**
455
454
  * Draw a pattern within the given rectangle.
456
455
  * @name drawPattern
457
- * @memberof me.WebGLRenderer.prototype
456
+ * @memberof WebGLRenderer.prototype
458
457
  * @function
459
- * @param {me.Renderer.Texture} pattern Pattern object
458
+ * @param {TextureAtlas} pattern Pattern object
460
459
  * @param {number} x
461
460
  * @param {number} y
462
461
  * @param {number} width
463
462
  * @param {number} height
464
- * @see me.WebGLRenderer#createPattern
463
+ * @see WebGLRenderer#createPattern
465
464
  */
466
465
  drawPattern(pattern, x, y, width, height) {
467
466
  var uvs = pattern.getUVs("0,0," + width + "," + height);
@@ -472,7 +471,7 @@ class WebGLRenderer extends Renderer {
472
471
  /**
473
472
  * return a reference to the screen canvas corresponding WebGL Context
474
473
  * @name getScreenContext
475
- * @memberof me.WebGLRenderer.prototype
474
+ * @memberof WebGLRenderer.prototype
476
475
  * @function
477
476
  * @returns {WebGLRenderingContext}
478
477
  */
@@ -483,7 +482,7 @@ class WebGLRenderer extends Renderer {
483
482
  /**
484
483
  * Returns the WebGL Context object of the given Canvas
485
484
  * @name getContextGL
486
- * @memberof me.WebGLRenderer.prototype
485
+ * @memberof WebGLRenderer.prototype
487
486
  * @function
488
487
  * @param {HTMLCanvasElement} canvas
489
488
  * @param {boolean} [transparent=true] use false to disable transparency
@@ -541,7 +540,7 @@ class WebGLRenderer extends Renderer {
541
540
  * Returns the WebGLContext instance for the renderer
542
541
  * return a reference to the system 2d Context
543
542
  * @name getContext
544
- * @memberof me.WebGLRenderer.prototype
543
+ * @memberof WebGLRenderer.prototype
545
544
  * @function
546
545
  * @returns {WebGLRenderingContext}
547
546
  */
@@ -552,7 +551,7 @@ class WebGLRenderer extends Renderer {
552
551
  /**
553
552
  * set a blend mode for the given context
554
553
  * @name setBlendMode
555
- * @memberof me.WebGLRenderer.prototype
554
+ * @memberof WebGLRenderer.prototype
556
555
  * @function
557
556
  * @param {string} [mode="normal"] blend mode : "normal", "multiply"
558
557
  * @param {WebGLRenderingContext} [gl]
@@ -592,7 +591,7 @@ class WebGLRenderer extends Renderer {
592
591
  /**
593
592
  * restores the canvas context
594
593
  * @name restore
595
- * @memberof me.WebGLRenderer.prototype
594
+ * @memberof WebGLRenderer.prototype
596
595
  * @function
597
596
  */
598
597
  restore() {
@@ -626,7 +625,7 @@ class WebGLRenderer extends Renderer {
626
625
  /**
627
626
  * saves the canvas context
628
627
  * @name save
629
- * @memberof me.WebGLRenderer.prototype
628
+ * @memberof WebGLRenderer.prototype
630
629
  * @function
631
630
  */
632
631
  save() {
@@ -642,7 +641,7 @@ class WebGLRenderer extends Renderer {
642
641
  /**
643
642
  * rotates the uniform matrix
644
643
  * @name rotate
645
- * @memberof me.WebGLRenderer.prototype
644
+ * @memberof WebGLRenderer.prototype
646
645
  * @function
647
646
  * @param {number} angle in radians
648
647
  */
@@ -653,7 +652,7 @@ class WebGLRenderer extends Renderer {
653
652
  /**
654
653
  * scales the uniform matrix
655
654
  * @name scale
656
- * @memberof me.WebGLRenderer.prototype
655
+ * @memberof WebGLRenderer.prototype
657
656
  * @function
658
657
  * @param {number} x
659
658
  * @param {number} y
@@ -674,7 +673,7 @@ class WebGLRenderer extends Renderer {
674
673
  /**
675
674
  * Set the global alpha
676
675
  * @name setGlobalAlpha
677
- * @memberof me.WebGLRenderer.prototype
676
+ * @memberof WebGLRenderer.prototype
678
677
  * @function
679
678
  * @param {number} alpha 0.0 to 1.0 values accepted.
680
679
  */
@@ -686,9 +685,9 @@ class WebGLRenderer extends Renderer {
686
685
  * Set the current fill & stroke style color.
687
686
  * By default, or upon reset, the value is set to #000000.
688
687
  * @name setColor
689
- * @memberof me.WebGLRenderer.prototype
688
+ * @memberof WebGLRenderer.prototype
690
689
  * @function
691
- * @param {me.Color|string} color css color string.
690
+ * @param {Color|string} color css color string.
692
691
  */
693
692
  setColor(color) {
694
693
  var alpha = this.currentColor.alpha;
@@ -699,7 +698,7 @@ class WebGLRenderer extends Renderer {
699
698
  /**
700
699
  * Set the line width
701
700
  * @name setLineWidth
702
- * @memberof me.WebGLRenderer.prototype
701
+ * @memberof WebGLRenderer.prototype
703
702
  * @function
704
703
  * @param {number} width Line width
705
704
  */
@@ -710,7 +709,7 @@ class WebGLRenderer extends Renderer {
710
709
  /**
711
710
  * Stroke an arc at the specified coordinates with given radius, start and end points
712
711
  * @name strokeArc
713
- * @memberof me.WebGLRenderer.prototype
712
+ * @memberof WebGLRenderer.prototype
714
713
  * @function
715
714
  * @param {number} x arc center point x-axis
716
715
  * @param {number} y arc center point y-axis
@@ -754,7 +753,7 @@ class WebGLRenderer extends Renderer {
754
753
  /**
755
754
  * Fill an arc at the specified coordinates with given radius, start and end points
756
755
  * @name fillArc
757
- * @memberof me.WebGLRenderer.prototype
756
+ * @memberof WebGLRenderer.prototype
758
757
  * @function
759
758
  * @param {number} x arc center point x-axis
760
759
  * @param {number} y arc center point y-axis
@@ -797,7 +796,7 @@ class WebGLRenderer extends Renderer {
797
796
  /**
798
797
  * Stroke an ellipse at the specified coordinates with given radius
799
798
  * @name strokeEllipse
800
- * @memberof me.WebGLRenderer.prototype
799
+ * @memberof WebGLRenderer.prototype
801
800
  * @function
802
801
  * @param {number} x ellipse center point x-axis
803
802
  * @param {number} y ellipse center point y-axis
@@ -834,7 +833,7 @@ class WebGLRenderer extends Renderer {
834
833
  /**
835
834
  * Fill an ellipse at the specified coordinates with given radius
836
835
  * @name fillEllipse
837
- * @memberof me.WebGLRenderer.prototype
836
+ * @memberof WebGLRenderer.prototype
838
837
  * @function
839
838
  * @param {number} x ellipse center point x-axis
840
839
  * @param {number} y ellipse center point y-axis
@@ -869,7 +868,7 @@ class WebGLRenderer extends Renderer {
869
868
  /**
870
869
  * Stroke a line of the given two points
871
870
  * @name strokeLine
872
- * @memberof me.WebGLRenderer.prototype
871
+ * @memberof WebGLRenderer.prototype
873
872
  * @function
874
873
  * @param {number} startX the start x coordinate
875
874
  * @param {number} startY the start y coordinate
@@ -889,7 +888,7 @@ class WebGLRenderer extends Renderer {
889
888
  /**
890
889
  * Fill a line of the given two points
891
890
  * @name fillLine
892
- * @memberof me.WebGLRenderer.prototype
891
+ * @memberof WebGLRenderer.prototype
893
892
  * @function
894
893
  * @param {number} startX the start x coordinate
895
894
  * @param {number} startY the start y coordinate
@@ -903,9 +902,9 @@ class WebGLRenderer extends Renderer {
903
902
  /**
904
903
  * Stroke a me.Polygon on the screen with a specified color
905
904
  * @name strokePolygon
906
- * @memberof me.WebGLRenderer.prototype
905
+ * @memberof WebGLRenderer.prototype
907
906
  * @function
908
- * @param {me.Polygon} poly the shape to draw
907
+ * @param {Polygon} poly the shape to draw
909
908
  * @param {boolean} [fill=false] also fill the shape with the current color if true
910
909
  */
911
910
  strokePolygon(poly, fill = false) {
@@ -933,9 +932,9 @@ class WebGLRenderer extends Renderer {
933
932
  /**
934
933
  * Fill a me.Polygon on the screen
935
934
  * @name fillPolygon
936
- * @memberof me.WebGLRenderer.prototype
935
+ * @memberof WebGLRenderer.prototype
937
936
  * @function
938
- * @param {me.Polygon} poly the shape to draw
937
+ * @param {Polygon} poly the shape to draw
939
938
  */
940
939
  fillPolygon(poly) {
941
940
  var points = poly.points;
@@ -961,7 +960,7 @@ class WebGLRenderer extends Renderer {
961
960
  /**
962
961
  * Draw a stroke rectangle at the specified coordinates
963
962
  * @name strokeRect
964
- * @memberof me.WebGLRenderer.prototype
963
+ * @memberof WebGLRenderer.prototype
965
964
  * @function
966
965
  * @param {number} x
967
966
  * @param {number} y
@@ -989,7 +988,7 @@ class WebGLRenderer extends Renderer {
989
988
  /**
990
989
  * Draw a filled rectangle at the specified coordinates
991
990
  * @name fillRect
992
- * @memberof me.WebGLRenderer.prototype
991
+ * @memberof WebGLRenderer.prototype
993
992
  * @function
994
993
  * @param {number} x
995
994
  * @param {number} y
@@ -1013,9 +1012,9 @@ class WebGLRenderer extends Renderer {
1013
1012
  * Reset (overrides) the renderer transformation matrix to the
1014
1013
  * identity one, and then apply the given transformation matrix.
1015
1014
  * @name setTransform
1016
- * @memberof me.WebGLRenderer.prototype
1015
+ * @memberof WebGLRenderer.prototype
1017
1016
  * @function
1018
- * @param {me.Matrix2d} mat2d Matrix to transform by
1017
+ * @param {Matrix2d} mat2d Matrix to transform by
1019
1018
  */
1020
1019
  setTransform(mat2d) {
1021
1020
  this.resetTransform();
@@ -1025,9 +1024,9 @@ class WebGLRenderer extends Renderer {
1025
1024
  /**
1026
1025
  * Multiply given matrix into the renderer tranformation matrix
1027
1026
  * @name transform
1028
- * @memberof me.WebGLRenderer.prototype
1027
+ * @memberof WebGLRenderer.prototype
1029
1028
  * @function
1030
- * @param {me.Matrix2d} mat2d Matrix to transform by
1029
+ * @param {Matrix2d} mat2d Matrix to transform by
1031
1030
  */
1032
1031
  transform(mat2d) {
1033
1032
  var currentTransform = this.currentTransform;
@@ -1043,7 +1042,7 @@ class WebGLRenderer extends Renderer {
1043
1042
  /**
1044
1043
  * Translates the uniform matrix by the given coordinates
1045
1044
  * @name translate
1046
- * @memberof me.WebGLRenderer.prototype
1045
+ * @memberof WebGLRenderer.prototype
1047
1046
  * @function
1048
1047
  * @param {number} x
1049
1048
  * @param {number} y
@@ -1066,7 +1065,7 @@ class WebGLRenderer extends Renderer {
1066
1065
  * and restore it (with the restore() method) any time in the future.
1067
1066
  * (<u>this is an experimental feature !</u>)
1068
1067
  * @name clipRect
1069
- * @memberof me.WebGLRenderer.prototype
1068
+ * @memberof WebGLRenderer.prototype
1070
1069
  * @function
1071
1070
  * @param {number} x
1072
1071
  * @param {number} y
@@ -1114,9 +1113,9 @@ class WebGLRenderer extends Renderer {
1114
1113
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
1115
1114
  * Mask are not preserved through renderer context save and restore.
1116
1115
  * @name setMask
1117
- * @memberof me.WebGLRenderer.prototype
1116
+ * @memberof WebGLRenderer.prototype
1118
1117
  * @function
1119
- * @param {me.Rect|me.Polygon|me.Line|me.Ellipse} [mask] the shape defining the mask to be applied
1118
+ * @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
1120
1119
  */
1121
1120
  setMask(mask) {
1122
1121
  var gl = this.gl;
@@ -1145,8 +1144,8 @@ class WebGLRenderer extends Renderer {
1145
1144
  /**
1146
1145
  * disable (remove) the rendering mask set through setMask.
1147
1146
  * @name clearMask
1148
- * @see me.WebGLRenderer#setMask
1149
- * @memberof me.WebGLRenderer.prototype
1147
+ * @see WebGLRenderer#setMask
1148
+ * @memberof WebGLRenderer.prototype
1150
1149
  * @function
1151
1150
  */
1152
1151
  clearMask() {
@@ -1,130 +0,0 @@
1
- import Vector2d from "./../math/vector2.js";
2
- import * as input from "./../input/input.js";
3
- import * as event from "./../system/event.js";
4
- import Entity from "./entity.js";
5
-
6
- /**
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
- class DraggableEntity extends Entity {
17
-
18
- constructor(x, y, settings) {
19
- super(x, y, settings);
20
- this.dragging = false;
21
- this.dragId = null;
22
- this.grabOffset = new Vector2d(0, 0);
23
- this.onPointerEvent = input.registerPointerEvent;
24
- this.removePointerEvent = input.releasePointerEvent;
25
- this.initEvents();
26
- }
27
-
28
- /**
29
- * Initializes the events the modules needs to listen to
30
- * It translates the pointer events to me.events
31
- * in order to make them pass through the system and to make
32
- * this module testable. Then we subscribe this module to the
33
- * transformed events.
34
- * @name initEvents
35
- * @memberof me.DraggableEntity
36
- * @function
37
- */
38
- initEvents() {
39
- /**
40
- * @ignore
41
- */
42
- this.mouseDown = function (e) {
43
- this.translatePointerEvent(e, event.DRAGSTART);
44
- };
45
- /**
46
- * @ignore
47
- */
48
- this.mouseUp = function (e) {
49
- this.translatePointerEvent(e, event.DRAGEND);
50
- };
51
- this.onPointerEvent("pointerdown", this, this.mouseDown.bind(this));
52
- this.onPointerEvent("pointerup", this, this.mouseUp.bind(this));
53
- this.onPointerEvent("pointercancel", this, this.mouseUp.bind(this));
54
- event.on(event.POINTERMOVE, this.dragMove, this);
55
- event.on(event.DRAGSTART, this.dragStart, this);
56
- event.on(event.DRAGEND, this.dragEnd, this);
57
- }
58
-
59
- /**
60
- * Translates a pointer event to a me.event
61
- * @name translatePointerEvent
62
- * @memberof me.DraggableEntity
63
- * @function
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
66
- */
67
- translatePointerEvent(e, translation) {
68
- event.emit(translation, e);
69
- }
70
-
71
- /**
72
- * Gets called when the user starts dragging the entity
73
- * @name dragStart
74
- * @memberof me.DraggableEntity
75
- * @function
76
- * @param {object} e the pointer event
77
- * @returns {boolean} false if the object is being dragged
78
- */
79
- dragStart(e) {
80
- if (this.dragging === false) {
81
- this.dragging = true;
82
- this.grabOffset.set(e.gameX, e.gameY);
83
- this.grabOffset.sub(this.pos);
84
- return false;
85
- }
86
- }
87
-
88
- /**
89
- * Gets called when the user drags this entity around
90
- * @name dragMove
91
- * @memberof me.DraggableEntity
92
- * @function
93
- * @param {object} e the pointer event
94
- */
95
- dragMove(e) {
96
- if (this.dragging === true) {
97
- this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ?
98
- this.pos.sub(this.grabOffset);
99
- }
100
- }
101
-
102
- /**
103
- * Gets called when the user stops dragging the entity
104
- * @name dragEnd
105
- * @memberof me.DraggableEntity
106
- * @function
107
- * @returns {boolean} false if the object stopped being dragged
108
- */
109
- dragEnd() {
110
- if (this.dragging === true) {
111
- this.dragging = false;
112
- return false;
113
- }
114
- }
115
-
116
- /**
117
- * Destructor
118
- * @name destroy
119
- * @memberof me.DraggableEntity
120
- * @function
121
- */
122
- destroy() {
123
- event.off(event.POINTERMOVE, this.dragMove);
124
- event.off(event.DRAGSTART, this.dragStart);
125
- event.off(event.DRAGEND, this.dragEnd);
126
- this.removePointerEvent("pointerdown", this);
127
- this.removePointerEvent("pointerup", this);
128
- }
129
- };
130
- export default DraggableEntity;