melonjs 14.0.1 → 14.1.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 +2 -0
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +10 -0
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/earcut.js +10 -0
- package/dist/melonjs.mjs/_virtual/howler.js +10 -0
- package/dist/melonjs.mjs/_virtual/index.js +10 -0
- package/dist/melonjs.mjs/_virtual/index2.js +10 -0
- package/dist/melonjs.mjs/_virtual/multimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/setmultimap.js +10 -0
- package/dist/melonjs.mjs/application/application.js +240 -0
- package/dist/melonjs.mjs/audio/audio.js +536 -0
- package/dist/melonjs.mjs/camera/camera2d.js +732 -0
- package/dist/melonjs.mjs/entity/entity.js +248 -0
- package/dist/melonjs.mjs/game.js +29 -0
- package/dist/melonjs.mjs/geometries/ellipse.js +275 -0
- package/dist/melonjs.mjs/geometries/line.js +116 -0
- package/dist/melonjs.mjs/geometries/path2d.js +319 -0
- package/dist/melonjs.mjs/geometries/point.js +89 -0
- package/dist/melonjs.mjs/geometries/poly.js +500 -0
- package/dist/melonjs.mjs/geometries/rectangle.js +375 -0
- package/dist/melonjs.mjs/geometries/roundrect.js +168 -0
- package/dist/melonjs.mjs/index.js +248 -0
- package/dist/melonjs.mjs/input/gamepad.js +501 -0
- package/dist/melonjs.mjs/input/input.js +26 -0
- package/dist/melonjs.mjs/input/keyboard.js +470 -0
- package/dist/melonjs.mjs/input/pointer.js +393 -0
- package/dist/melonjs.mjs/input/pointerevent.js +818 -0
- package/dist/melonjs.mjs/lang/deprecated.js +157 -0
- package/dist/melonjs.mjs/level/level.js +297 -0
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +141 -0
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +448 -0
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +355 -0
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +194 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +639 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +311 -0
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +83 -0
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +367 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +506 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +220 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +157 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +125 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +109 -0
- package/dist/melonjs.mjs/loader/loader.js +801 -0
- package/dist/melonjs.mjs/loader/loadingscreen.js +120 -0
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +11 -0
- package/dist/melonjs.mjs/math/color.js +618 -0
- package/dist/melonjs.mjs/math/math.js +218 -0
- package/dist/melonjs.mjs/math/matrix2.js +503 -0
- package/dist/melonjs.mjs/math/matrix3.js +681 -0
- package/dist/melonjs.mjs/math/observable_vector2.js +471 -0
- package/dist/melonjs.mjs/math/observable_vector3.js +561 -0
- package/dist/melonjs.mjs/math/vector2.js +528 -0
- package/dist/melonjs.mjs/math/vector3.js +569 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +73 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +21 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +324 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +69 -0
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +691 -0
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +350 -0
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3241 -0
- package/dist/melonjs.mjs/particles/emitter.js +267 -0
- package/dist/melonjs.mjs/particles/particle.js +188 -0
- package/dist/melonjs.mjs/particles/settings.js +319 -0
- package/dist/melonjs.mjs/physics/body.js +704 -0
- package/dist/melonjs.mjs/physics/bounds.js +460 -0
- package/dist/melonjs.mjs/physics/collision.js +132 -0
- package/dist/melonjs.mjs/physics/detector.js +194 -0
- package/dist/melonjs.mjs/physics/quadtree.js +391 -0
- package/dist/melonjs.mjs/physics/response.js +57 -0
- package/dist/melonjs.mjs/physics/sat.js +483 -0
- package/dist/melonjs.mjs/physics/world.js +221 -0
- package/dist/melonjs.mjs/plugin/plugin.js +141 -0
- package/dist/melonjs.mjs/renderable/collectable.js +62 -0
- package/dist/melonjs.mjs/renderable/colorlayer.js +80 -0
- package/dist/melonjs.mjs/renderable/container.js +1018 -0
- package/dist/melonjs.mjs/renderable/dragndrop.js +224 -0
- package/dist/melonjs.mjs/renderable/imagelayer.js +306 -0
- package/dist/melonjs.mjs/renderable/light2d.js +156 -0
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +247 -0
- package/dist/melonjs.mjs/renderable/renderable.js +783 -0
- package/dist/melonjs.mjs/renderable/sprite.js +654 -0
- package/dist/melonjs.mjs/renderable/trigger.js +157 -0
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +213 -0
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +226 -0
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +128 -0
- package/dist/melonjs.mjs/state/stage.js +237 -0
- package/dist/melonjs.mjs/state/state.js +596 -0
- package/dist/melonjs.mjs/system/device.js +909 -0
- package/dist/melonjs.mjs/system/dom.js +78 -0
- package/dist/melonjs.mjs/system/event.js +537 -0
- package/dist/melonjs.mjs/system/platform.js +41 -0
- package/dist/melonjs.mjs/system/pooling.js +209 -0
- package/dist/melonjs.mjs/system/save.js +157 -0
- package/dist/melonjs.mjs/system/timer.js +286 -0
- package/dist/melonjs.mjs/text/bitmaptext.js +364 -0
- package/dist/melonjs.mjs/text/bitmaptextdata.js +199 -0
- package/dist/melonjs.mjs/text/glyph.js +66 -0
- package/dist/melonjs.mjs/text/text.js +453 -0
- package/dist/melonjs.mjs/text/textmetrics.js +176 -0
- package/dist/melonjs.mjs/text/textstyle.js +23 -0
- package/dist/melonjs.mjs/tweens/easing.js +336 -0
- package/dist/melonjs.mjs/tweens/interpolation.js +112 -0
- package/dist/melonjs.mjs/tweens/tween.js +480 -0
- package/dist/melonjs.mjs/utils/agent.js +76 -0
- package/dist/melonjs.mjs/utils/array.js +63 -0
- package/dist/melonjs.mjs/utils/file.js +42 -0
- package/dist/melonjs.mjs/utils/function.js +70 -0
- package/dist/melonjs.mjs/utils/string.js +82 -0
- package/dist/melonjs.mjs/utils/utils.js +173 -0
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +807 -0
- package/dist/melonjs.mjs/video/renderer.js +411 -0
- package/dist/melonjs.mjs/video/texture/atlas.js +519 -0
- package/dist/melonjs.mjs/video/texture/cache.js +143 -0
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +144 -0
- package/dist/melonjs.mjs/video/video.js +462 -0
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +143 -0
- package/dist/melonjs.mjs/video/webgl/glshader.js +168 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -0
- package/dist/melonjs.mjs/video/webgl/utils/program.js +67 -0
- package/dist/melonjs.mjs/video/webgl/utils/string.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +92 -0
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +495 -0
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1036 -0
- package/dist/melonjs.module.d.ts +1163 -1163
- package/dist/melonjs.module.js +1903 -3274
- package/package.json +22 -17
- package/src/application/application.js +3 -3
- package/src/audio/audio.js +32 -32
- package/src/camera/camera2d.js +31 -31
- package/src/entity/entity.js +17 -17
- package/src/geometries/ellipse.js +16 -16
- package/src/geometries/line.js +5 -5
- package/src/geometries/path2d.js +32 -32
- package/src/geometries/poly.js +15 -15
- package/src/geometries/rectangle.js +18 -18
- package/src/geometries/roundrect.js +8 -8
- package/src/input/gamepad.js +15 -15
- package/src/input/keyboard.js +12 -12
- package/src/input/pointer.js +6 -6
- package/src/input/pointerevent.js +12 -12
- package/src/lang/deprecated.js +12 -12
- package/src/level/level.js +25 -25
- package/src/level/tiled/TMXLayer.js +22 -22
- package/src/level/tiled/TMXTile.js +5 -5
- package/src/level/tiled/TMXTileMap.js +6 -6
- package/src/level/tiled/TMXTileset.js +2 -2
- package/src/level/tiled/TMXUtils.js +5 -5
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +19 -19
- package/src/loader/loader.js +20 -20
- package/src/math/color.js +20 -20
- package/src/math/math.js +16 -16
- package/src/math/matrix2.js +16 -16
- package/src/math/matrix3.js +25 -25
- package/src/math/observable_vector2.js +14 -14
- package/src/math/observable_vector3.js +16 -16
- package/src/math/vector2.js +9 -9
- package/src/math/vector3.js +10 -10
- package/src/particles/emitter.js +6 -6
- package/src/particles/particle.js +2 -2
- package/src/physics/body.js +28 -28
- package/src/physics/bounds.js +8 -8
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +6 -6
- package/src/physics/quadtree.js +11 -11
- package/src/physics/sat.js +31 -31
- package/src/physics/world.js +5 -5
- package/src/plugin/plugin.js +5 -5
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +5 -5
- package/src/renderable/container.js +21 -21
- package/src/renderable/dragndrop.js +14 -14
- package/src/renderable/imagelayer.js +13 -13
- package/src/renderable/light2d.js +3 -3
- package/src/renderable/nineslicesprite.js +16 -16
- package/src/renderable/renderable.js +23 -23
- package/src/renderable/sprite.js +28 -28
- package/src/renderable/trigger.js +15 -15
- package/src/renderable/ui/uibaseelement.js +7 -7
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +13 -13
- package/src/state/stage.js +7 -7
- package/src/state/state.js +17 -17
- package/src/system/device.js +11 -11
- package/src/system/event.js +10 -10
- package/src/system/pooling.js +9 -9
- package/src/system/save.js +2 -2
- package/src/system/timer.js +10 -10
- package/src/text/bitmaptext.js +18 -18
- package/src/text/bitmaptextdata.js +2 -2
- package/src/text/text.js +23 -23
- package/src/text/textmetrics.js +8 -8
- package/src/tweens/tween.js +19 -19
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +2 -2
- package/src/utils/function.js +6 -6
- package/src/utils/string.js +5 -5
- package/src/utils/utils.js +4 -4
- package/src/video/canvas/canvas_renderer.js +70 -70
- package/src/video/renderer.js +26 -26
- package/src/video/texture/atlas.js +22 -22
- package/src/video/texture/canvas_texture.js +9 -9
- package/src/video/video.js +17 -17
- package/src/video/webgl/glshader.js +10 -10
- package/src/video/webgl/webgl_compositor.js +41 -41
- package/src/video/webgl/webgl_renderer.js +75 -75
package/src/level/level.js
CHANGED
|
@@ -51,10 +51,10 @@ function safeLoadLevel(levelId, options, restart) {
|
|
|
51
51
|
* @name loadTMXLevel
|
|
52
52
|
* @memberof level
|
|
53
53
|
* @private
|
|
54
|
-
* @param {string} levelId level id
|
|
55
|
-
* @param {Container} container target container
|
|
56
|
-
* @param {boolean} [flatten=true] if true, flatten all objects into the given container
|
|
57
|
-
* @param {boolean} [setViewportBounds=false] if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.
|
|
54
|
+
* @param {string} levelId - level id
|
|
55
|
+
* @param {Container} container - target container
|
|
56
|
+
* @param {boolean} [flatten=true] - if true, flatten all objects into the given container
|
|
57
|
+
* @param {boolean} [setViewportBounds=false] - if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.
|
|
58
58
|
* @ignore
|
|
59
59
|
*/
|
|
60
60
|
function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
|
|
@@ -84,9 +84,9 @@ var level = {
|
|
|
84
84
|
* @name add
|
|
85
85
|
* @memberof level
|
|
86
86
|
* @public
|
|
87
|
-
* @param {string} format level format (only "tmx" supported)
|
|
88
|
-
* @param {string} levelId the level id (or name)
|
|
89
|
-
* @param {Function} [callback] a function to be called once the level is loaded
|
|
87
|
+
* @param {string} format - level format (only "tmx" supported)
|
|
88
|
+
* @param {string} levelId - the level id (or name)
|
|
89
|
+
* @param {Function} [callback] - a function to be called once the level is loaded
|
|
90
90
|
* @returns {boolean} true if the level was loaded
|
|
91
91
|
*/
|
|
92
92
|
add(format, levelId, callback) {
|
|
@@ -122,12 +122,12 @@ var level = {
|
|
|
122
122
|
* @name load
|
|
123
123
|
* @memberof level
|
|
124
124
|
* @public
|
|
125
|
-
* @param {string} levelId level id
|
|
126
|
-
* @param {object} [options] additional optional parameters
|
|
127
|
-
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
128
|
-
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
129
|
-
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
130
|
-
* @param {boolean} [options.setViewportBounds=true] if true, set the viewport bounds to the map size
|
|
125
|
+
* @param {string} levelId - level id
|
|
126
|
+
* @param {object} [options] - additional optional parameters
|
|
127
|
+
* @param {Container} [options.container=game.world] - container in which to load the specified level
|
|
128
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] - callback for when the level is fully loaded
|
|
129
|
+
* @param {boolean} [options.flatten=game.mergeGroup] - if true, flatten all objects into the given container
|
|
130
|
+
* @param {boolean} [options.setViewportBounds=true] - if true, set the viewport bounds to the map size
|
|
131
131
|
* @returns {boolean} true if the level was successfully loaded
|
|
132
132
|
* @example
|
|
133
133
|
* // the game assets to be be preloaded
|
|
@@ -219,10 +219,10 @@ var level = {
|
|
|
219
219
|
* @name reload
|
|
220
220
|
* @memberof level
|
|
221
221
|
* @public
|
|
222
|
-
* @param {object} [options] additional optional parameters
|
|
223
|
-
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
224
|
-
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
225
|
-
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
222
|
+
* @param {object} [options] - additional optional parameters
|
|
223
|
+
* @param {Container} [options.container=game.world] - container in which to load the specified level
|
|
224
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] - callback for when the level is fully loaded
|
|
225
|
+
* @param {boolean} [options.flatten=game.mergeGroup] - if true, flatten all objects into the given container
|
|
226
226
|
* @returns {object} the current level
|
|
227
227
|
*/
|
|
228
228
|
reload(options) {
|
|
@@ -236,10 +236,10 @@ var level = {
|
|
|
236
236
|
* @name next
|
|
237
237
|
* @memberof level
|
|
238
238
|
* @public
|
|
239
|
-
* @param {object} [options] additional optional parameters
|
|
240
|
-
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
241
|
-
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
242
|
-
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
239
|
+
* @param {object} [options] - additional optional parameters
|
|
240
|
+
* @param {Container} [options.container=game.world] - container in which to load the specified level
|
|
241
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] - callback for when the level is fully loaded
|
|
242
|
+
* @param {boolean} [options.flatten=game.mergeGroup] - if true, flatten all objects into the given container
|
|
243
243
|
* @returns {boolean} true if the next level was successfully loaded
|
|
244
244
|
*/
|
|
245
245
|
next(options) {
|
|
@@ -257,10 +257,10 @@ var level = {
|
|
|
257
257
|
* @name previous
|
|
258
258
|
* @memberof level
|
|
259
259
|
* @public
|
|
260
|
-
* @param {object} [options] additional optional parameters
|
|
261
|
-
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
262
|
-
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
263
|
-
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
260
|
+
* @param {object} [options] - additional optional parameters
|
|
261
|
+
* @param {Container} [options.container=game.world] - container in which to load the specified level
|
|
262
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] - callback for when the level is fully loaded
|
|
263
|
+
* @param {boolean} [options.flatten=game.mergeGroup] - if true, flatten all objects into the given container
|
|
264
264
|
* @returns {boolean} true if the previous level was successfully loaded
|
|
265
265
|
*/
|
|
266
266
|
previous(options) {
|
|
@@ -70,13 +70,13 @@ function preRenderLayer(layer, renderer) {
|
|
|
70
70
|
*/
|
|
71
71
|
class TMXLayer extends Renderable {
|
|
72
72
|
/**
|
|
73
|
-
* @param {object} map layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
74
|
-
* @param {object} data layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
75
|
-
* @param {number} tilewidth width of each tile in pixels
|
|
76
|
-
* @param {number} tileheight height of each tile in pixels
|
|
77
|
-
* @param {string} orientation "isometric" or "orthogonal"
|
|
78
|
-
* @param {TMXTilesetGroup} tilesets tileset as defined in Tiled
|
|
79
|
-
* @param {number} z z-index position
|
|
73
|
+
* @param {object} map - layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
74
|
+
* @param {object} data - layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
75
|
+
* @param {number} tilewidth - width of each tile in pixels
|
|
76
|
+
* @param {number} tileheight - height of each tile in pixels
|
|
77
|
+
* @param {string} orientation - "isometric" or "orthogonal"
|
|
78
|
+
* @param {TMXTilesetGroup} tilesets - tileset as defined in Tiled
|
|
79
|
+
* @param {number} z - z-index position
|
|
80
80
|
*/
|
|
81
81
|
constructor(map, data, tilewidth, tileheight, orientation, tilesets, z) {
|
|
82
82
|
// super constructor
|
|
@@ -278,8 +278,8 @@ class TMXLayer extends Renderable {
|
|
|
278
278
|
* @name getTileId
|
|
279
279
|
* @memberof TMXLayer
|
|
280
280
|
* @public
|
|
281
|
-
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
282
|
-
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
281
|
+
* @param {number} x - X coordinate (in world/pixels coordinates)
|
|
282
|
+
* @param {number} y - Y coordinate (in world/pixels coordinates)
|
|
283
283
|
* @returns {number} TileId or null if there is no Tile at the given position
|
|
284
284
|
*/
|
|
285
285
|
getTileId(x, y) {
|
|
@@ -292,8 +292,8 @@ class TMXLayer extends Renderable {
|
|
|
292
292
|
* @name getTile
|
|
293
293
|
* @memberof TMXLayer
|
|
294
294
|
* @public
|
|
295
|
-
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
296
|
-
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
295
|
+
* @param {number} x - X coordinate (in world/pixels coordinates)
|
|
296
|
+
* @param {number} y - Y coordinate (in world/pixels coordinates)
|
|
297
297
|
* @returns {Tile} corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds
|
|
298
298
|
* @example
|
|
299
299
|
* // get the TMX Map Layer called "Front layer"
|
|
@@ -317,9 +317,9 @@ class TMXLayer extends Renderable {
|
|
|
317
317
|
* @name getTile
|
|
318
318
|
* @memberof TMXLayer
|
|
319
319
|
* @public
|
|
320
|
-
* @param {Tile} tile the tile object to be assigned
|
|
321
|
-
* @param {number} x x coordinate (in world/pixels coordinates)
|
|
322
|
-
* @param {number} y y coordinate (in world/pixels coordinates)
|
|
320
|
+
* @param {Tile} tile - the tile object to be assigned
|
|
321
|
+
* @param {number} x - x coordinate (in world/pixels coordinates)
|
|
322
|
+
* @param {number} y - y coordinate (in world/pixels coordinates)
|
|
323
323
|
* @returns {Tile} the tile object
|
|
324
324
|
*/
|
|
325
325
|
setTile(tile, x, y) {
|
|
@@ -332,9 +332,9 @@ class TMXLayer extends Renderable {
|
|
|
332
332
|
* @name setTile
|
|
333
333
|
* @memberof TMXLayer
|
|
334
334
|
* @public
|
|
335
|
-
* @param {number} tileId tileId
|
|
336
|
-
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
337
|
-
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
335
|
+
* @param {number} tileId - tileId
|
|
336
|
+
* @param {number} x - X coordinate (in world/pixels coordinates)
|
|
337
|
+
* @param {number} y - Y coordinate (in world/pixels coordinates)
|
|
338
338
|
* @returns {Tile} the tile object
|
|
339
339
|
*/
|
|
340
340
|
getTileById(tileId, x, y) {
|
|
@@ -350,9 +350,9 @@ class TMXLayer extends Renderable {
|
|
|
350
350
|
* @name cellAt
|
|
351
351
|
* @memberof TMXLayer
|
|
352
352
|
* @public
|
|
353
|
-
* @param {number} x x position of the tile (in Tile unit)
|
|
354
|
-
* @param {number} y x position of the tile (in Tile unit)
|
|
355
|
-
* @param {number} [boundsCheck=true] check first if within the layer bounds
|
|
353
|
+
* @param {number} x - x position of the tile (in Tile unit)
|
|
354
|
+
* @param {number} y - x position of the tile (in Tile unit)
|
|
355
|
+
* @param {number} [boundsCheck=true] - check first if within the layer bounds
|
|
356
356
|
* @returns {Tile} corresponding tile or null if there is no defined tile at the position or if outside of the layer bounds
|
|
357
357
|
* @example
|
|
358
358
|
* // return the first tile at offset 0, 0
|
|
@@ -376,8 +376,8 @@ class TMXLayer extends Renderable {
|
|
|
376
376
|
* @name clearTile
|
|
377
377
|
* @memberof TMXLayer
|
|
378
378
|
* @public
|
|
379
|
-
* @param {number} x X coordinate (in map coordinates: row/column)
|
|
380
|
-
* @param {number} y Y coordinate (in map coordinates: row/column)
|
|
379
|
+
* @param {number} x - X coordinate (in map coordinates: row/column)
|
|
380
|
+
* @param {number} y - Y coordinate (in map coordinates: row/column)
|
|
381
381
|
* @example
|
|
382
382
|
* me.game.world.getChildByType(me.TMXLayer).forEach(function(layer) {
|
|
383
383
|
* // clear all tiles at the given x,y coordinates
|
|
@@ -15,10 +15,10 @@ const TMX_FLIP_H = 0x80000000,
|
|
|
15
15
|
*/
|
|
16
16
|
class Tile extends Bounds {
|
|
17
17
|
/**
|
|
18
|
-
* @param {number} x x index of the Tile in the map
|
|
19
|
-
* @param {number} y y index of the Tile in the map
|
|
20
|
-
* @param {number} gid tile gid
|
|
21
|
-
* @param {TMXTileset} tileset the corresponding tileset object
|
|
18
|
+
* @param {number} x - x index of the Tile in the map
|
|
19
|
+
* @param {number} y - y index of the Tile in the map
|
|
20
|
+
* @param {number} gid - tile gid
|
|
21
|
+
* @param {TMXTileset} tileset - the corresponding tileset object
|
|
22
22
|
*/
|
|
23
23
|
constructor(x, y, gid, tileset) {
|
|
24
24
|
var width, height;
|
|
@@ -132,7 +132,7 @@ class Tile extends Bounds {
|
|
|
132
132
|
* return a renderable object for this Tile object
|
|
133
133
|
* @name Tile#getRenderable
|
|
134
134
|
* @public
|
|
135
|
-
* @param {object} [settings] see {@link Sprite}
|
|
135
|
+
* @param {object} [settings] - see {@link Sprite}
|
|
136
136
|
* @returns {Renderable} a me.Sprite object
|
|
137
137
|
*/
|
|
138
138
|
getRenderable(settings) {
|
|
@@ -105,8 +105,8 @@ function readObjectGroup(map, data, z) {
|
|
|
105
105
|
*/
|
|
106
106
|
class TMXTileMap {
|
|
107
107
|
/**
|
|
108
|
-
* @param {string} levelId name of TMX map
|
|
109
|
-
* @param {object} data TMX map in JSON format
|
|
108
|
+
* @param {string} levelId - name of TMX map
|
|
109
|
+
* @param {object} data - TMX map in JSON format
|
|
110
110
|
* @example
|
|
111
111
|
* // create a new level object based on the TMX JSON object
|
|
112
112
|
* var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
|
|
@@ -361,9 +361,9 @@ class TMXTileMap {
|
|
|
361
361
|
* note : this will not automatically update the camera viewport
|
|
362
362
|
* @name TMXTileMap#addTo
|
|
363
363
|
* @public
|
|
364
|
-
* @param {Container} container target container
|
|
365
|
-
* @param {boolean} [flatten=true] if true, flatten all objects into the given container, else a `me.Container` object will be created for each corresponding groups
|
|
366
|
-
* @param {boolean} [setViewportBounds=false] if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.
|
|
364
|
+
* @param {Container} container - target container
|
|
365
|
+
* @param {boolean} [flatten=true] - if true, flatten all objects into the given container, else a `me.Container` object will be created for each corresponding groups
|
|
366
|
+
* @param {boolean} [setViewportBounds=false] - if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.
|
|
367
367
|
* @example
|
|
368
368
|
* // create a new level object based on the TMX JSON object
|
|
369
369
|
* var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
|
|
@@ -437,7 +437,7 @@ class TMXTileMap {
|
|
|
437
437
|
* return an Array of instantiated objects, based on the map object definition
|
|
438
438
|
* @name TMXTileMap#getObjects
|
|
439
439
|
* @public
|
|
440
|
-
* @param {boolean} [flatten=true] if true, flatten all objects into the returned array.
|
|
440
|
+
* @param {boolean} [flatten=true] - if true, flatten all objects into the returned array.
|
|
441
441
|
* when false, a `me.Container` object will be created for each corresponding groups
|
|
442
442
|
* @returns {Renderable[]} Array of Objects
|
|
443
443
|
*/
|
|
@@ -10,7 +10,7 @@ import loader from "./../../loader/loader.js";
|
|
|
10
10
|
*/
|
|
11
11
|
class TMXTileset {
|
|
12
12
|
/**
|
|
13
|
-
* @param {object} tileset tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
13
|
+
* @param {object} tileset - tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
14
14
|
*/
|
|
15
15
|
constructor(tileset) {
|
|
16
16
|
var i = 0;
|
|
@@ -206,7 +206,7 @@ class TMXTileset {
|
|
|
206
206
|
* Get the view (local) tile ID from a GID, with animations applied
|
|
207
207
|
* @name TMXTileset#getViewTileId
|
|
208
208
|
* @public
|
|
209
|
-
* @param {number} gid Global tile ID
|
|
209
|
+
* @param {number} gid - Global tile ID
|
|
210
210
|
* @returns {number} View tile ID
|
|
211
211
|
*/
|
|
212
212
|
getViewTileId(gid) {
|
|
@@ -99,8 +99,8 @@ function parseAttributes(obj, elt) {
|
|
|
99
99
|
* decompress zlib/gzip data (NOT IMPLEMENTED)
|
|
100
100
|
* @ignore
|
|
101
101
|
* @name decompress
|
|
102
|
-
* @param {number[]} data Array of bytes
|
|
103
|
-
* @param {string} format compressed data format ("gzip","zlib")
|
|
102
|
+
* @param {number[]} data- - Array of bytes
|
|
103
|
+
* @param {string} format- - compressed data format ("gzip","zlib")
|
|
104
104
|
*/
|
|
105
105
|
export function decompress() {
|
|
106
106
|
throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
|
|
@@ -110,7 +110,7 @@ export function decompress() {
|
|
|
110
110
|
* Decode a CSV encoded array into a binary array
|
|
111
111
|
* @ignore
|
|
112
112
|
* @name decodeCSV
|
|
113
|
-
* @param {string} input CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
113
|
+
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
114
114
|
* @returns {number[]} Decoded data
|
|
115
115
|
*/
|
|
116
116
|
export function decodeCSV(input) {
|
|
@@ -127,8 +127,8 @@ export function decodeCSV(input) {
|
|
|
127
127
|
* Decode a base64 encoded string into a byte array
|
|
128
128
|
* @ignore
|
|
129
129
|
* @name decodeBase64AsArray
|
|
130
|
-
* @param {string} input Base64 encoded data
|
|
131
|
-
* @param {number} [bytes] number of bytes per array entry
|
|
130
|
+
* @param {string} input - Base64 encoded data
|
|
131
|
+
* @param {number} [bytes] - number of bytes per array entry
|
|
132
132
|
* @returns {Uint32Array} Decoded data
|
|
133
133
|
*/
|
|
134
134
|
export function decodeBase64AsArray(input, bytes) {
|
|
@@ -26,7 +26,7 @@ const offsetsStaggerY = [
|
|
|
26
26
|
*/
|
|
27
27
|
class TMXHexagonalRenderer extends TMXRenderer {
|
|
28
28
|
/**
|
|
29
|
-
* @param {TMXTileMap} map the TMX map
|
|
29
|
+
* @param {TMXTileMap} map - the TMX map
|
|
30
30
|
*/
|
|
31
31
|
constructor(map) {
|
|
32
32
|
super(
|
|
@@ -81,7 +81,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
81
81
|
* return the bounding rect for this map renderer
|
|
82
82
|
* @name TMXHexagonalRenderer#getBounds
|
|
83
83
|
* @public
|
|
84
|
-
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
84
|
+
* @param {TMXLayer} [layer] - calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
85
85
|
* @returns {Bounds}
|
|
86
86
|
*/
|
|
87
87
|
getBounds(layer) {
|
|
@@ -11,7 +11,7 @@ import TMXLayer from "./../TMXLayer.js";
|
|
|
11
11
|
*/
|
|
12
12
|
class TMXIsometricRenderer extends TMXRenderer {
|
|
13
13
|
/**
|
|
14
|
-
* @param {TMXTileMap} map the TMX map
|
|
14
|
+
* @param {TMXTileMap} map - the TMX map
|
|
15
15
|
*/
|
|
16
16
|
constructor(map) {
|
|
17
17
|
super(
|
|
@@ -41,7 +41,7 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
41
41
|
* return the bounding rect for this map renderer
|
|
42
42
|
* @name TMXIsometricRenderer#getBounds
|
|
43
43
|
* @public
|
|
44
|
-
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
44
|
+
* @param {TMXLayer} [layer] - calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
45
45
|
* @returns {Bounds}
|
|
46
46
|
*/
|
|
47
47
|
getBounds(layer) {
|
|
@@ -10,10 +10,10 @@ import Bounds from "./../../../physics/bounds.js";
|
|
|
10
10
|
*/
|
|
11
11
|
class TMXRenderer {
|
|
12
12
|
/**
|
|
13
|
-
* @param {number} cols width of the tilemap in tiles
|
|
14
|
-
* @param {number} rows height of the tilemap in tiles
|
|
15
|
-
* @param {number} tilewidth width of each tile in pixels
|
|
16
|
-
* @param {number} tileheight height of each tile in pixels
|
|
13
|
+
* @param {number} cols - width of the tilemap in tiles
|
|
14
|
+
* @param {number} rows - height of the tilemap in tiles
|
|
15
|
+
* @param {number} tilewidth - width of each tile in pixels
|
|
16
|
+
* @param {number} tileheight - height of each tile in pixels
|
|
17
17
|
*/
|
|
18
18
|
constructor(cols, rows, tilewidth, tileheight) {
|
|
19
19
|
this.cols = cols;
|
|
@@ -27,7 +27,7 @@ class TMXRenderer {
|
|
|
27
27
|
* return true if the renderer can render the specified map or layer
|
|
28
28
|
* @name TMXRenderer#canRender
|
|
29
29
|
* @public
|
|
30
|
-
* @param {TMXTileMap|TMXLayer} component TMX Map or Layer
|
|
30
|
+
* @param {TMXTileMap|TMXLayer} component - TMX Map or Layer
|
|
31
31
|
* @returns {boolean}
|
|
32
32
|
*/
|
|
33
33
|
canRender(component) {
|
|
@@ -47,7 +47,7 @@ class TMXRenderer {
|
|
|
47
47
|
* return the bounding rect for this map renderer
|
|
48
48
|
* @name TMXRenderer#getBounds
|
|
49
49
|
* @public
|
|
50
|
-
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
50
|
+
* @param {TMXLayer} [layer] - calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
51
51
|
* @returns {Bounds}
|
|
52
52
|
*/
|
|
53
53
|
getBounds(layer) {
|
|
@@ -64,9 +64,9 @@ class TMXRenderer {
|
|
|
64
64
|
* return the tile position corresponding to the specified pixel
|
|
65
65
|
* @name TMXRenderer#pixelToTileCoords
|
|
66
66
|
* @public
|
|
67
|
-
* @param {number} x X coordinate
|
|
68
|
-
* @param {number} y Y coordinate
|
|
69
|
-
* @param {Vector2d} [v] an optional vector object where to put the return values
|
|
67
|
+
* @param {number} x - X coordinate
|
|
68
|
+
* @param {number} y - Y coordinate
|
|
69
|
+
* @param {Vector2d} [v] - an optional vector object where to put the return values
|
|
70
70
|
* @returns {Vector2d}
|
|
71
71
|
*/
|
|
72
72
|
pixelToTileCoords(x, y, v) {
|
|
@@ -77,9 +77,9 @@ class TMXRenderer {
|
|
|
77
77
|
* return the pixel position corresponding of the specified tile
|
|
78
78
|
* @name TMXRenderer#tileToPixelCoords
|
|
79
79
|
* @public
|
|
80
|
-
* @param {number} col tile horizontal position
|
|
81
|
-
* @param {number} row tile vertical position
|
|
82
|
-
* @param {Vector2d} [v] an optional vector object where to put the return values
|
|
80
|
+
* @param {number} col - tile horizontal position
|
|
81
|
+
* @param {number} row - tile vertical position
|
|
82
|
+
* @param {Vector2d} [v] - an optional vector object where to put the return values
|
|
83
83
|
* @returns {Vector2d}
|
|
84
84
|
*/
|
|
85
85
|
tileToPixelCoords(col, row, v) {
|
|
@@ -90,10 +90,10 @@ class TMXRenderer {
|
|
|
90
90
|
* draw the given tile at the specified layer
|
|
91
91
|
* @name TMXRenderer#drawTile
|
|
92
92
|
* @public
|
|
93
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
94
|
-
* @param {number} x X coordinate where to draw the tile
|
|
95
|
-
* @param {number} y Y coordinate where to draw the tile
|
|
96
|
-
* @param {Tile} tile the tile object to draw
|
|
93
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
|
|
94
|
+
* @param {number} x - X coordinate where to draw the tile
|
|
95
|
+
* @param {number} y - Y coordinate where to draw the tile
|
|
96
|
+
* @param {Tile} tile - the tile object to draw
|
|
97
97
|
*/
|
|
98
98
|
drawTile(renderer, x, y, tile) {
|
|
99
99
|
}
|
|
@@ -102,9 +102,9 @@ class TMXRenderer {
|
|
|
102
102
|
* draw the given TMX Layer for the given area
|
|
103
103
|
* @name TMXRenderer#drawTileLayer
|
|
104
104
|
* @public
|
|
105
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
106
|
-
* @param {TMXLayer} layer a TMX Layer object
|
|
107
|
-
* @param {Rect} rect the area of the layer to draw
|
|
105
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
|
|
106
|
+
* @param {TMXLayer} layer - a TMX Layer object
|
|
107
|
+
* @param {Rect} rect - the area of the layer to draw
|
|
108
108
|
*/
|
|
109
109
|
drawTileLayer(renderer, layer, rect) {
|
|
110
110
|
}
|
package/src/loader/loader.js
CHANGED
|
@@ -441,8 +441,8 @@ var loader = {
|
|
|
441
441
|
* @name setBaseURL
|
|
442
442
|
* @memberof loader
|
|
443
443
|
* @public
|
|
444
|
-
* @param {string} type "*", "audio", binary", "image", "json", "js", "tmx", "tsx"
|
|
445
|
-
* @param {string} [url="./"] default base URL
|
|
444
|
+
* @param {string} type - "*", "audio", binary", "image", "json", "js", "tmx", "tsx"
|
|
445
|
+
* @param {string} [url="./"] - default base URL
|
|
446
446
|
* @example
|
|
447
447
|
* // change the base URL relative address for audio assets
|
|
448
448
|
* me.loader.setBaseURL("audio", "data/audio/");
|
|
@@ -472,12 +472,12 @@ var loader = {
|
|
|
472
472
|
* @memberof loader
|
|
473
473
|
* @public
|
|
474
474
|
* @param {object[]} res
|
|
475
|
-
* @param {string} res.name internal name of the resource
|
|
476
|
-
* @param {string} res.type "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
|
|
477
|
-
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
478
|
-
* @param {boolean} [res.stream] Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
479
|
-
* @param {Function} [onload=loader.onload] function to be called when all resources are loaded
|
|
480
|
-
* @param {boolean} [switchToLoadState=true] automatically switch to the loading screen
|
|
475
|
+
* @param {string} res.name - internal name of the resource
|
|
476
|
+
* @param {string} res.type - "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
|
|
477
|
+
* @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
|
|
478
|
+
* @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
479
|
+
* @param {Function} [onload=loader.onload] - function to be called when all resources are loaded
|
|
480
|
+
* @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
|
|
481
481
|
* @example
|
|
482
482
|
* game_resources = [
|
|
483
483
|
* // PNG tileset
|
|
@@ -540,12 +540,12 @@ var loader = {
|
|
|
540
540
|
* @memberof loader
|
|
541
541
|
* @public
|
|
542
542
|
* @param {object} res
|
|
543
|
-
* @param {string} res.name internal name of the resource
|
|
544
|
-
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
545
|
-
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
546
|
-
* @param {boolean} [res.stream] Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
547
|
-
* @param {Function} [onload] function to be called when the resource is loaded
|
|
548
|
-
* @param {Function} [onerror] function to be called in case of error
|
|
543
|
+
* @param {string} res.name - internal name of the resource
|
|
544
|
+
* @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
|
|
545
|
+
* @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
|
|
546
|
+
* @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
547
|
+
* @param {Function} [onload] - function to be called when the resource is loaded
|
|
548
|
+
* @param {Function} [onerror] - function to be called in case of error
|
|
549
549
|
* @returns {number} the amount of corresponding resource to be preloaded
|
|
550
550
|
* @example
|
|
551
551
|
* // load an image asset
|
|
@@ -610,8 +610,8 @@ var loader = {
|
|
|
610
610
|
* @memberof loader
|
|
611
611
|
* @public
|
|
612
612
|
* @param {object} res
|
|
613
|
-
* @param {string} res.name internal name of the resource
|
|
614
|
-
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
613
|
+
* @param {string} res.name - internal name of the resource
|
|
614
|
+
* @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
|
|
615
615
|
* @returns {boolean} true if unloaded
|
|
616
616
|
* @example me.loader.unload({name: "avatar", type:"image"});
|
|
617
617
|
*/
|
|
@@ -724,7 +724,7 @@ var loader = {
|
|
|
724
724
|
* @name getTMX
|
|
725
725
|
* @memberof loader
|
|
726
726
|
* @public
|
|
727
|
-
* @param {string} elt name of the tmx/tsx element ("map1");
|
|
727
|
+
* @param {string} elt - name of the tmx/tsx element ("map1");
|
|
728
728
|
* @returns {object} requested element or null if not found
|
|
729
729
|
*/
|
|
730
730
|
getTMX(elt) {
|
|
@@ -741,7 +741,7 @@ var loader = {
|
|
|
741
741
|
* @name getBinary
|
|
742
742
|
* @memberof loader
|
|
743
743
|
* @public
|
|
744
|
-
* @param {string} elt name of the binary object ("ymTrack");
|
|
744
|
+
* @param {string} elt - name of the binary object ("ymTrack");
|
|
745
745
|
* @returns {object} requested element or null if not found
|
|
746
746
|
*/
|
|
747
747
|
getBinary(elt) {
|
|
@@ -758,7 +758,7 @@ var loader = {
|
|
|
758
758
|
* @name getImage
|
|
759
759
|
* @memberof loader
|
|
760
760
|
* @public
|
|
761
|
-
* @param {string} image name of the Image element ("tileset-platformer");
|
|
761
|
+
* @param {string} image - name of the Image element ("tileset-platformer");
|
|
762
762
|
* @returns {HTMLImageElement} requested element or null if not found
|
|
763
763
|
*/
|
|
764
764
|
getImage(image) {
|
|
@@ -776,7 +776,7 @@ var loader = {
|
|
|
776
776
|
* @name getJSON
|
|
777
777
|
* @memberof loader
|
|
778
778
|
* @public
|
|
779
|
-
* @param {string} elt name of the json file to load
|
|
779
|
+
* @param {string} elt - name of the json file to load
|
|
780
780
|
* @returns {object}
|
|
781
781
|
*/
|
|
782
782
|
getJSON(elt) {
|
package/src/math/color.js
CHANGED
|
@@ -184,10 +184,10 @@ var cssToRGB = new Map();
|
|
|
184
184
|
*/
|
|
185
185
|
class Color {
|
|
186
186
|
/**
|
|
187
|
-
* @param {number} [r=0] red component or array of color components
|
|
188
|
-
* @param {number} [g=0] green component
|
|
189
|
-
* @param {number} [b=0] blue component
|
|
190
|
-
* @param {number} [alpha=1.0] alpha value
|
|
187
|
+
* @param {number} [r=0] - red component or array of color components
|
|
188
|
+
* @param {number} [g=0] - green component
|
|
189
|
+
* @param {number} [b=0] - blue component
|
|
190
|
+
* @param {number} [alpha=1.0] - alpha value
|
|
191
191
|
*/
|
|
192
192
|
constructor(r = 0, g = 0, b = 0, alpha = 1.0) {
|
|
193
193
|
this.onResetEvent(r, g, b, alpha);
|
|
@@ -257,10 +257,10 @@ class Color {
|
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
259
|
* Set this color to the specified value.
|
|
260
|
-
* @param {number} r red component [0 .. 255]
|
|
261
|
-
* @param {number} g green component [0 .. 255]
|
|
262
|
-
* @param {number} b blue component [0 .. 255]
|
|
263
|
-
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
260
|
+
* @param {number} r - red component [0 .. 255]
|
|
261
|
+
* @param {number} g - green component [0 .. 255]
|
|
262
|
+
* @param {number} b - blue component [0 .. 255]
|
|
263
|
+
* @param {number} [alpha=1.0] - alpha value [0.0 .. 1.0]
|
|
264
264
|
* @returns {Color} Reference to this object for method chaining
|
|
265
265
|
*/
|
|
266
266
|
setColor(r, g, b, alpha = 1.0) {
|
|
@@ -273,9 +273,9 @@ class Color {
|
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
275
|
* set this color to the specified HSV value
|
|
276
|
-
* @param {number} h hue (a value from 0 to 1)
|
|
277
|
-
* @param {number} s saturation (a value from 0 to 1)
|
|
278
|
-
* @param {number} v value (a value from 0 to 1)
|
|
276
|
+
* @param {number} h - hue (a value from 0 to 1)
|
|
277
|
+
* @param {number} s - saturation (a value from 0 to 1)
|
|
278
|
+
* @param {number} v - value (a value from 0 to 1)
|
|
279
279
|
* @returns {Color} Reference to this object for method chaining
|
|
280
280
|
*/
|
|
281
281
|
setHSV(h, s, v) {
|
|
@@ -300,9 +300,9 @@ class Color {
|
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
302
|
* set this color to the specified HSL value
|
|
303
|
-
* @param {number} h hue (a value from 0 to 1)
|
|
304
|
-
* @param {number} s saturation (a value from 0 to 1)
|
|
305
|
-
* @param {number} l lightness (a value from 0 to 1)
|
|
303
|
+
* @param {number} h - hue (a value from 0 to 1)
|
|
304
|
+
* @param {number} s - saturation (a value from 0 to 1)
|
|
305
|
+
* @param {number} l - lightness (a value from 0 to 1)
|
|
306
306
|
* @returns {Color} Reference to this object for method chaining
|
|
307
307
|
*/
|
|
308
308
|
setHSL(h, s, l) {
|
|
@@ -375,7 +375,7 @@ class Color {
|
|
|
375
375
|
/**
|
|
376
376
|
* Linearly interpolate between this color and the given one.
|
|
377
377
|
* @param {Color} color
|
|
378
|
-
* @param {number} alpha with alpha = 0 being this color, and alpha = 1 being the given one.
|
|
378
|
+
* @param {number} alpha - with alpha = 0 being this color, and alpha = 1 being the given one.
|
|
379
379
|
* @returns {Color} Reference to this object for method chaining
|
|
380
380
|
*/
|
|
381
381
|
lerp(color, alpha) {
|
|
@@ -403,8 +403,8 @@ class Color {
|
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
405
|
* Generate random r,g,b values for this color object
|
|
406
|
-
* @param {number} [min=0] minimum value for the random range
|
|
407
|
-
* @param {number} [max=255] maxmium value for the random range
|
|
406
|
+
* @param {number} [min=0] - minimum value for the random range
|
|
407
|
+
* @param {number} [max=255] - maxmium value for the random range
|
|
408
408
|
* @returns {Color} Reference to this object for method chaining
|
|
409
409
|
*/
|
|
410
410
|
random(min = 0, max = 255) {
|
|
@@ -474,7 +474,7 @@ class Color {
|
|
|
474
474
|
* Parse a Hex color ("#RGB", "#RGBA" or "#RRGGBB", "#RRGGBBAA" format) and set this color to
|
|
475
475
|
* the corresponding r,g,b,a values
|
|
476
476
|
* @param {string} hexColor
|
|
477
|
-
* @param {boolean} [argb = false] true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)
|
|
477
|
+
* @param {boolean} [argb = false] - true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)
|
|
478
478
|
* @returns {Color} Reference to this object for method chaining
|
|
479
479
|
*/
|
|
480
480
|
parseHex(hexColor, argb = false) {
|
|
@@ -530,7 +530,7 @@ class Color {
|
|
|
530
530
|
|
|
531
531
|
/**
|
|
532
532
|
* Pack this color into a Uint32 ARGB representation
|
|
533
|
-
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
533
|
+
* @param {number} [alpha=1.0] - alpha value [0.0 .. 1.0]
|
|
534
534
|
* @returns {number}
|
|
535
535
|
*/
|
|
536
536
|
toUint32(alpha = 1.0) {
|
|
@@ -590,7 +590,7 @@ class Color {
|
|
|
590
590
|
|
|
591
591
|
/**
|
|
592
592
|
* Get the color in "rgba(R,G,B,A)" format
|
|
593
|
-
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
593
|
+
* @param {number} [alpha=1.0] - alpha value [0.0 .. 1.0]
|
|
594
594
|
* @returns {string}
|
|
595
595
|
*/
|
|
596
596
|
toRGBA(alpha = this.alpha) {
|