melonjs 10.2.2 → 10.4.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 +2907 -3383
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3620 -4528
- package/dist/melonjs.module.js +3210 -3331
- package/package.json +19 -19
- package/src/audio/audio.js +30 -31
- package/src/camera/camera2d.js +47 -58
- package/src/entity/draggable.js +11 -21
- package/src/entity/droptarget.js +12 -22
- 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 +9 -20
- 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 +44 -14
- 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 +38 -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 +8 -10
- 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 +47 -146
- package/src/physics/bounds.js +48 -50
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +14 -14
- package/src/physics/quadtree.js +18 -21
- 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/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 +4 -6
- package/src/video/video.js +16 -17
- 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 -110
- package/src/video/webgl/webgl_renderer.js +126 -106
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"keywords": [
|
|
@@ -59,38 +59,38 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@rollup/plugin-buble": "^0.21.3",
|
|
62
|
-
"@rollup/plugin-commonjs": "^21.0.
|
|
63
|
-
"@rollup/plugin-node-resolve": "^13.1.
|
|
64
|
-
"@rollup/plugin-replace": "^
|
|
62
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
63
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
64
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
65
65
|
"cheerio": "^1.0.0-rc.10",
|
|
66
66
|
"del-cli": "^4.0.1",
|
|
67
|
-
"eslint": "^8.
|
|
68
|
-
"eslint-plugin-jsdoc": "^37.
|
|
69
|
-
"jasmine-core": "^
|
|
70
|
-
"jsdoc": "^3.6.
|
|
71
|
-
"karma": "^6.3.
|
|
67
|
+
"eslint": "^8.10.0",
|
|
68
|
+
"eslint-plugin-jsdoc": "^37.9.7",
|
|
69
|
+
"jasmine-core": "^4.0.1",
|
|
70
|
+
"jsdoc": "^3.6.10",
|
|
71
|
+
"karma": "^6.3.17",
|
|
72
72
|
"karma-chrome-launcher": "^3.1.0",
|
|
73
|
-
"karma-coverage": "^2.
|
|
73
|
+
"karma-coverage": "^2.2.0",
|
|
74
74
|
"karma-html-detailed-reporter": "^2.1.0",
|
|
75
75
|
"karma-jasmine": "^4.0.1",
|
|
76
76
|
"karma-nyan-reporter": "0.2.5",
|
|
77
|
-
"qs": "^6.10.
|
|
78
|
-
"rollup": "^2.
|
|
77
|
+
"qs": "^6.10.3",
|
|
78
|
+
"rollup": "^2.70.0",
|
|
79
79
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
80
80
|
"rollup-plugin-string": "^3.0.0",
|
|
81
|
-
"terser": "^5.
|
|
82
|
-
"typescript": "^4.
|
|
81
|
+
"terser": "^5.12.0",
|
|
82
|
+
"typescript": "^4.6.2",
|
|
83
|
+
"@types/offscreencanvas": "^2019.6.4"
|
|
83
84
|
},
|
|
84
85
|
"scripts": {
|
|
85
86
|
"build": "npm run lint && rollup -c --silent",
|
|
86
|
-
"dist": " npm run build && npm run minify && mkdirp dist && cp -f build/*.js dist/ && npm run
|
|
87
|
+
"dist": " npm run build && npm run minify && mkdirp dist && cp -f build/*.js dist/ && npm run types",
|
|
87
88
|
"minify": "terser build/melonjs.js --compress --mangle --comments '/(?:^!|@(?:license|preserve|cc_on))/' --output build/melonjs.min.js",
|
|
88
|
-
"lint": "eslint
|
|
89
|
+
"lint": "eslint src rollup.config.js",
|
|
89
90
|
"test": "npm run build && karma start tests/karma.conf.js",
|
|
90
91
|
"doc": "mkdirp docs && jsdoc -c jsdoc_conf.json",
|
|
91
92
|
"release": "npm run dist && npm publish --access public",
|
|
92
|
-
"clean": "del-cli --force build/*.js docs src/**/*.d.ts",
|
|
93
|
-
"
|
|
94
|
-
"make-separated-src-dts": "npm run clean && npx -p typescript tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly"
|
|
93
|
+
"clean": "del-cli --force build/*.js dist/*.js dist/*.d.ts docs src/**/*.d.ts",
|
|
94
|
+
"types": "tsc dist/melonjs.module.js --declaration --allowJs --emitDeclarationOnly"
|
|
95
95
|
}
|
|
96
96
|
}
|
package/src/audio/audio.js
CHANGED
|
@@ -5,7 +5,6 @@ import loader from "./../loader/loader.js";
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @namespace audio
|
|
8
|
-
* @memberOf me
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -70,7 +69,7 @@ var soundLoadError = function (sound_name, onerror_cb) {
|
|
|
70
69
|
* @name stopOnAudioError
|
|
71
70
|
* @type {boolean}
|
|
72
71
|
* @default true
|
|
73
|
-
* @
|
|
72
|
+
* @memberof audio
|
|
74
73
|
*/
|
|
75
74
|
export let stopOnAudioError = true;
|
|
76
75
|
|
|
@@ -83,7 +82,7 @@ export let stopOnAudioError = true;
|
|
|
83
82
|
* webm has nearly full browser coverage with a great combination of compression and quality, and mp3 will fallback gracefully for other browsers.
|
|
84
83
|
* It is important to remember that melonJS selects the first compatible sound based on the list of extensions and given order passed here.
|
|
85
84
|
* So if you want webm to be used before mp3, you need to put the audio format in that order.
|
|
86
|
-
* @function
|
|
85
|
+
* @function audio.init
|
|
87
86
|
* @param {string} [format="mp3"] audio format to prioritize
|
|
88
87
|
* @returns {boolean} Indicates whether audio initialization was successful
|
|
89
88
|
* @example
|
|
@@ -102,7 +101,7 @@ export let stopOnAudioError = true;
|
|
|
102
101
|
|
|
103
102
|
/**
|
|
104
103
|
* check if the given audio format is supported
|
|
105
|
-
* @function
|
|
104
|
+
* @function audio.hasFormat
|
|
106
105
|
* @param {string} codec audio format : "mp3", "mpeg", opus", "ogg", "oga", "wav", "aac", "caf", "m4a", "m4b", "mp4", "weba", "webm", "dolby", "flac"
|
|
107
106
|
* @returns {boolean} return true if the given audio format is supported
|
|
108
107
|
*/
|
|
@@ -112,7 +111,7 @@ export function hasFormat(codec) {
|
|
|
112
111
|
|
|
113
112
|
/**
|
|
114
113
|
* check if audio (HTML5 or WebAudio) is supported
|
|
115
|
-
* @function
|
|
114
|
+
* @function audio.hasAudio
|
|
116
115
|
* @returns {boolean} return true if audio (HTML5 or WebAudio) is supported
|
|
117
116
|
*/
|
|
118
117
|
export function hasAudio() {
|
|
@@ -122,8 +121,8 @@ export function hasAudio() {
|
|
|
122
121
|
/**
|
|
123
122
|
* enable audio output <br>
|
|
124
123
|
* only useful if audio supported and previously disabled through
|
|
125
|
-
* @function
|
|
126
|
-
* @see
|
|
124
|
+
* @function audio.enable
|
|
125
|
+
* @see audio#disable
|
|
127
126
|
*/
|
|
128
127
|
export function enable() {
|
|
129
128
|
unmuteAll();
|
|
@@ -131,7 +130,7 @@ export function enable() {
|
|
|
131
130
|
|
|
132
131
|
/**
|
|
133
132
|
* disable audio output
|
|
134
|
-
* @function
|
|
133
|
+
* @function audio.disable
|
|
135
134
|
*/
|
|
136
135
|
export function disable() {
|
|
137
136
|
muteAll();
|
|
@@ -180,7 +179,7 @@ export function load(sound, html5, onload_cb, onerror_cb) {
|
|
|
180
179
|
|
|
181
180
|
/**
|
|
182
181
|
* play the specified sound
|
|
183
|
-
* @function
|
|
182
|
+
* @function audio.play
|
|
184
183
|
* @param {string} sound_name audio clip name - case sensitive
|
|
185
184
|
* @param {boolean} [loop=false] loop audio
|
|
186
185
|
* @param {Function} [onend] Function to call when sound instance ends playing.
|
|
@@ -221,7 +220,7 @@ export function play(sound_name, loop = false, onend, volume) {
|
|
|
221
220
|
|
|
222
221
|
/**
|
|
223
222
|
* Fade a currently playing sound between two volumee.
|
|
224
|
-
* @function
|
|
223
|
+
* @function audio.fade
|
|
225
224
|
* @param {string} sound_name audio clip name - case sensitive
|
|
226
225
|
* @param {number} from Volume to fade from (0.0 to 1.0).
|
|
227
226
|
* @param {number} to Volume to fade to (0.0 to 1.0).
|
|
@@ -239,9 +238,9 @@ export function fade(sound_name, from, to, duration, id) {
|
|
|
239
238
|
|
|
240
239
|
/**
|
|
241
240
|
* get/set the position of playback for a sound.
|
|
242
|
-
* @function
|
|
241
|
+
* @function audio.seek
|
|
243
242
|
* @param {string} sound_name audio clip name - case sensitive
|
|
244
|
-
* @param {number} [seek]
|
|
243
|
+
* @param {number} [seek] the position to move current playback to (in seconds).
|
|
245
244
|
* @param {number} [id] the sound instance ID. If none is passed, all sounds in group will changed.
|
|
246
245
|
* @returns {number} return the current seek position (if no extra parameters were given)
|
|
247
246
|
* @example
|
|
@@ -261,7 +260,7 @@ export function seek(sound_name, ...args) {
|
|
|
261
260
|
|
|
262
261
|
/**
|
|
263
262
|
* get or set the rate of playback for a sound.
|
|
264
|
-
* @function
|
|
263
|
+
* @function audio.rate
|
|
265
264
|
* @param {string} sound_name audio clip name - case sensitive
|
|
266
265
|
* @param {number} [rate] playback rate : 0.5 to 4.0, with 1.0 being normal speed.
|
|
267
266
|
* @param {number} [id] the sound instance ID. If none is passed, all sounds in group will be changed.
|
|
@@ -283,7 +282,7 @@ export function rate(sound_name, ...args) {
|
|
|
283
282
|
|
|
284
283
|
/**
|
|
285
284
|
* stop the specified sound on all channels
|
|
286
|
-
* @function
|
|
285
|
+
* @function audio.stop
|
|
287
286
|
* @param {string} [sound_name] audio clip name (case sensitive). If none is passed, all sounds are stopped.
|
|
288
287
|
* @param {number} [id] the sound instance ID. If none is passed, all sounds in group will stop.
|
|
289
288
|
* @example
|
|
@@ -307,7 +306,7 @@ export function stop(sound_name, id) {
|
|
|
307
306
|
/**
|
|
308
307
|
* pause the specified sound on all channels<br>
|
|
309
308
|
* this function does not reset the currentTime property
|
|
310
|
-
* @function
|
|
309
|
+
* @function audio.pause
|
|
311
310
|
* @param {string} sound_name audio clip name - case sensitive
|
|
312
311
|
* @param {number} [id] the sound instance ID. If none is passed, all sounds in group will pause.
|
|
313
312
|
* @example
|
|
@@ -324,7 +323,7 @@ export function pause(sound_name, id) {
|
|
|
324
323
|
|
|
325
324
|
/**
|
|
326
325
|
* resume the specified sound on all channels<br>
|
|
327
|
-
* @function
|
|
326
|
+
* @function audio.resume
|
|
328
327
|
* @param {string} sound_name audio clip name - case sensitive
|
|
329
328
|
* @param {number} [id] the sound instance ID. If none is passed, all sounds in group will resume.
|
|
330
329
|
* @example
|
|
@@ -350,7 +349,7 @@ export function resume(sound_name, id) {
|
|
|
350
349
|
* play the specified audio track<br>
|
|
351
350
|
* this function automatically set the loop property to true<br>
|
|
352
351
|
* and keep track of the current sound being played.
|
|
353
|
-
* @function
|
|
352
|
+
* @function audio.playTrack
|
|
354
353
|
* @param {string} sound_name audio track name - case sensitive
|
|
355
354
|
* @param {number} [volume=default] Float specifying volume (0.0 - 1.0 values accepted).
|
|
356
355
|
* @returns {number} the sound instance ID.
|
|
@@ -369,8 +368,8 @@ export function playTrack(sound_name, volume) {
|
|
|
369
368
|
|
|
370
369
|
/**
|
|
371
370
|
* stop the current audio track
|
|
372
|
-
* @function
|
|
373
|
-
* @see
|
|
371
|
+
* @function audio.stopTrack
|
|
372
|
+
* @see audio#playTrack
|
|
374
373
|
* @example
|
|
375
374
|
* // play a awesome music
|
|
376
375
|
* me.audio.playTrack("awesome_music");
|
|
@@ -386,7 +385,7 @@ export function stopTrack() {
|
|
|
386
385
|
|
|
387
386
|
/**
|
|
388
387
|
* pause the current audio track
|
|
389
|
-
* @function
|
|
388
|
+
* @function audio.pauseTrack
|
|
390
389
|
* @example
|
|
391
390
|
* me.audio.pauseTrack();
|
|
392
391
|
*/
|
|
@@ -398,7 +397,7 @@ export function pauseTrack() {
|
|
|
398
397
|
|
|
399
398
|
/**
|
|
400
399
|
* resume the previously paused audio track
|
|
401
|
-
* @function
|
|
400
|
+
* @function audio.resumeTrack
|
|
402
401
|
* @example
|
|
403
402
|
* // play an awesome music
|
|
404
403
|
* me.audio.playTrack("awesome_music");
|
|
@@ -415,7 +414,7 @@ export function resumeTrack() {
|
|
|
415
414
|
|
|
416
415
|
/**
|
|
417
416
|
* returns the current track Id
|
|
418
|
-
* @function
|
|
417
|
+
* @function audio.getCurrentTrack
|
|
419
418
|
* @returns {string} audio track name
|
|
420
419
|
*/
|
|
421
420
|
export function getCurrentTrack() {
|
|
@@ -424,7 +423,7 @@ export function getCurrentTrack() {
|
|
|
424
423
|
|
|
425
424
|
/**
|
|
426
425
|
* set the default global volume
|
|
427
|
-
* @function
|
|
426
|
+
* @function audio.setVolume
|
|
428
427
|
* @param {number} volume Float specifying volume (0.0 - 1.0 values accepted).
|
|
429
428
|
*/
|
|
430
429
|
export function setVolume(volume) {
|
|
@@ -433,7 +432,7 @@ export function setVolume(volume) {
|
|
|
433
432
|
|
|
434
433
|
/**
|
|
435
434
|
* get the default global volume
|
|
436
|
-
* @function
|
|
435
|
+
* @function audio.getVolume
|
|
437
436
|
* @returns {number} current volume value in Float [0.0 - 1.0] .
|
|
438
437
|
*/
|
|
439
438
|
export function getVolume() {
|
|
@@ -442,7 +441,7 @@ export function getVolume() {
|
|
|
442
441
|
|
|
443
442
|
/**
|
|
444
443
|
* mute or unmute the specified sound, but does not pause the playback.
|
|
445
|
-
* @function
|
|
444
|
+
* @function audio.mute
|
|
446
445
|
* @param {string} sound_name audio clip name - case sensitive
|
|
447
446
|
* @param {number} [id] the sound instance ID. If none is passed, all sounds in group will mute.
|
|
448
447
|
* @param {boolean} [mute=true] True to mute and false to unmute
|
|
@@ -463,7 +462,7 @@ export function mute(sound_name, id, mute) {
|
|
|
463
462
|
|
|
464
463
|
/**
|
|
465
464
|
* unmute the specified sound
|
|
466
|
-
* @function
|
|
465
|
+
* @function audio.unmute
|
|
467
466
|
* @param {string} sound_name audio clip name
|
|
468
467
|
* @param {number} [id] the sound instance ID. If none is passed, all sounds in group will unmute.
|
|
469
468
|
*/
|
|
@@ -473,7 +472,7 @@ export function unmute(sound_name, id) {
|
|
|
473
472
|
|
|
474
473
|
/**
|
|
475
474
|
* mute all audio
|
|
476
|
-
* @function
|
|
475
|
+
* @function audio.muteAll
|
|
477
476
|
*/
|
|
478
477
|
export function muteAll() {
|
|
479
478
|
Howler.mute(true);
|
|
@@ -481,7 +480,7 @@ export function muteAll() {
|
|
|
481
480
|
|
|
482
481
|
/**
|
|
483
482
|
* unmute all audio
|
|
484
|
-
* @function
|
|
483
|
+
* @function audio.unmuteAll
|
|
485
484
|
*/
|
|
486
485
|
export function unmuteAll() {
|
|
487
486
|
Howler.mute(false);
|
|
@@ -489,7 +488,7 @@ export function unmuteAll() {
|
|
|
489
488
|
|
|
490
489
|
/**
|
|
491
490
|
* Returns true if audio is muted globally.
|
|
492
|
-
* @function
|
|
491
|
+
* @function audio.muted
|
|
493
492
|
* @returns {boolean} true if audio is muted globally
|
|
494
493
|
*/
|
|
495
494
|
export function muted() {
|
|
@@ -498,7 +497,7 @@ export function muted() {
|
|
|
498
497
|
|
|
499
498
|
/**
|
|
500
499
|
* unload specified audio track to free memory
|
|
501
|
-
* @function
|
|
500
|
+
* @function audio.unload
|
|
502
501
|
* @param {string} sound_name audio track name - case sensitive
|
|
503
502
|
* @returns {boolean} true if unloaded
|
|
504
503
|
* @example
|
|
@@ -517,7 +516,7 @@ export function unload(sound_name) {
|
|
|
517
516
|
|
|
518
517
|
/**
|
|
519
518
|
* unload all audio to free memory
|
|
520
|
-
* @function
|
|
519
|
+
* @function audio.unloadAll
|
|
521
520
|
* @function
|
|
522
521
|
* @example
|
|
523
522
|
* me.audio.unloadAll();
|
package/src/camera/camera2d.js
CHANGED
|
@@ -4,7 +4,7 @@ import ObservableVector2d from "./../math/observable_vector2.js";
|
|
|
4
4
|
import ObservableVector3d from "./../math/observable_vector3.js";
|
|
5
5
|
import Matrix2d from "./../math/matrix2.js";
|
|
6
6
|
import Matrix3d from "./../math/matrix3.js";
|
|
7
|
-
import Rect from "./../
|
|
7
|
+
import Rect from "./../geometries/rectangle.js";
|
|
8
8
|
import { renderer } from "./../video/video.js";
|
|
9
9
|
import * as event from "./../system/event.js";
|
|
10
10
|
import pool from "./../system/pooling.js";
|
|
@@ -21,34 +21,28 @@ var targetV = new Vector2d();
|
|
|
21
21
|
/**
|
|
22
22
|
* @classdesc
|
|
23
23
|
* a 2D orthographic camera
|
|
24
|
-
* @
|
|
25
|
-
* @extends me.Renderable
|
|
26
|
-
* @memberOf me
|
|
27
|
-
* @constructor
|
|
28
|
-
* @param {number} minX start x offset
|
|
29
|
-
* @param {number} minY start y offset
|
|
30
|
-
* @param {number} maxX end x offset
|
|
31
|
-
* @param {number} maxY end y offset
|
|
24
|
+
* @augments Renderable
|
|
32
25
|
*/
|
|
33
26
|
class Camera2d extends Renderable {
|
|
34
|
-
|
|
35
27
|
/**
|
|
36
|
-
* @
|
|
28
|
+
* @param {number} minX start x offset
|
|
29
|
+
* @param {number} minY start y offset
|
|
30
|
+
* @param {number} maxX end x offset
|
|
31
|
+
* @param {number} maxY end y offset
|
|
37
32
|
*/
|
|
38
33
|
constructor(minX, minY, maxX, maxY) {
|
|
39
34
|
super(minX, minY, maxX - minX, maxY - minY);
|
|
40
35
|
|
|
41
36
|
/**
|
|
42
37
|
* Axis definition
|
|
38
|
+
* @enum {number}
|
|
43
39
|
* @property {number} NONE no axis
|
|
44
40
|
* @property {number} HORIZONTAL horizontal axis only
|
|
45
41
|
* @property {number} VERTICAL vertical axis only
|
|
46
42
|
* @property {number} BOTH both axis
|
|
47
|
-
* @
|
|
48
|
-
* @constant
|
|
49
|
-
* @enum {number}
|
|
43
|
+
* @readonly
|
|
50
44
|
* @name AXIS
|
|
51
|
-
* @
|
|
45
|
+
* @memberof Camera2d
|
|
52
46
|
*/
|
|
53
47
|
this.AXIS = {
|
|
54
48
|
NONE : 0,
|
|
@@ -60,20 +54,16 @@ class Camera2d extends Renderable {
|
|
|
60
54
|
/**
|
|
61
55
|
* Camera bounds
|
|
62
56
|
* @public
|
|
63
|
-
* @type {
|
|
57
|
+
* @type {Bounds}
|
|
64
58
|
* @name bounds
|
|
65
|
-
* @
|
|
59
|
+
* @memberof Camera2d
|
|
66
60
|
*/
|
|
67
61
|
this.bounds = pool.pull("Bounds");
|
|
68
62
|
|
|
69
63
|
/**
|
|
70
|
-
*
|
|
64
|
+
* enable or disable damping
|
|
71
65
|
* @private
|
|
72
|
-
* @type {boolean}
|
|
73
|
-
* @name smoothFollow
|
|
74
|
-
* @see me.Camera2d.damping
|
|
75
66
|
* @default true
|
|
76
|
-
* @memberOf me.Camera2d
|
|
77
67
|
*/
|
|
78
68
|
this.smoothFollow = true;
|
|
79
69
|
|
|
@@ -84,7 +74,7 @@ class Camera2d extends Renderable {
|
|
|
84
74
|
* @type {number}
|
|
85
75
|
* @name damping
|
|
86
76
|
* @default 1.0
|
|
87
|
-
* @
|
|
77
|
+
* @memberof Camera2d
|
|
88
78
|
*/
|
|
89
79
|
this.damping = 1.0;
|
|
90
80
|
|
|
@@ -94,7 +84,7 @@ class Camera2d extends Renderable {
|
|
|
94
84
|
* @type {number}
|
|
95
85
|
* @name near
|
|
96
86
|
* @default -1000
|
|
97
|
-
* @
|
|
87
|
+
* @memberof Camera2d
|
|
98
88
|
*/
|
|
99
89
|
this.near = -1000;
|
|
100
90
|
|
|
@@ -104,7 +94,7 @@ class Camera2d extends Renderable {
|
|
|
104
94
|
* @type {number}
|
|
105
95
|
* @name far
|
|
106
96
|
* @default 1000
|
|
107
|
-
* @
|
|
97
|
+
* @memberof Camera2d
|
|
108
98
|
*/
|
|
109
99
|
this.far = 1000;
|
|
110
100
|
|
|
@@ -112,18 +102,18 @@ class Camera2d extends Renderable {
|
|
|
112
102
|
* the default camera projection matrix
|
|
113
103
|
* (2d cameras use an orthographic projection by default).
|
|
114
104
|
* @public
|
|
115
|
-
* @type {
|
|
105
|
+
* @type {Matrix3d}
|
|
116
106
|
* @name projectionMatrix
|
|
117
|
-
* @
|
|
107
|
+
* @memberof Camera2d
|
|
118
108
|
*/
|
|
119
109
|
this.projectionMatrix = new Matrix3d();
|
|
120
110
|
|
|
121
111
|
/**
|
|
122
112
|
* the invert camera transform used to unproject points
|
|
123
113
|
* @ignore
|
|
124
|
-
* @type {
|
|
114
|
+
* @type {Matrix2d}
|
|
125
115
|
* @name invCurrentTransform
|
|
126
|
-
* @
|
|
116
|
+
* @memberof Camera2d
|
|
127
117
|
*/
|
|
128
118
|
this.invCurrentTransform = new Matrix2d();
|
|
129
119
|
|
|
@@ -216,7 +206,7 @@ class Camera2d extends Renderable {
|
|
|
216
206
|
/**
|
|
217
207
|
* reset the camera position to specified coordinates
|
|
218
208
|
* @name reset
|
|
219
|
-
* @
|
|
209
|
+
* @memberof Camera2d
|
|
220
210
|
* @function
|
|
221
211
|
* @param {number} [x=0]
|
|
222
212
|
* @param {number} [y=0]
|
|
@@ -246,8 +236,8 @@ class Camera2d extends Renderable {
|
|
|
246
236
|
* the "deadzone" defines an area within the current camera in which
|
|
247
237
|
* the followed renderable can move without scrolling the camera.
|
|
248
238
|
* @name setDeadzone
|
|
249
|
-
* @see
|
|
250
|
-
* @
|
|
239
|
+
* @see Camera2d.follow
|
|
240
|
+
* @memberof Camera2d
|
|
251
241
|
* @function
|
|
252
242
|
* @param {number} w deadzone width
|
|
253
243
|
* @param {number} h deadzone height
|
|
@@ -275,11 +265,11 @@ class Camera2d extends Renderable {
|
|
|
275
265
|
/**
|
|
276
266
|
* resize the camera
|
|
277
267
|
* @name resize
|
|
278
|
-
* @
|
|
268
|
+
* @memberof Camera2d
|
|
279
269
|
* @function
|
|
280
270
|
* @param {number} w new width of the camera
|
|
281
271
|
* @param {number} h new height of the camera
|
|
282
|
-
* @returns {
|
|
272
|
+
* @returns {Camera2d} this camera
|
|
283
273
|
*/
|
|
284
274
|
resize(w, h) {
|
|
285
275
|
// parent consctructor, resize camera rect
|
|
@@ -307,7 +297,7 @@ class Camera2d extends Renderable {
|
|
|
307
297
|
* set the camera boundaries (set to the world limit by default).
|
|
308
298
|
* the camera is bound to the given coordinates and cannot move/be scrolled outside of it.
|
|
309
299
|
* @name setBounds
|
|
310
|
-
* @
|
|
300
|
+
* @memberof Camera2d
|
|
311
301
|
* @function
|
|
312
302
|
* @param {number} x world left limit
|
|
313
303
|
* @param {number} y world top limit
|
|
@@ -326,10 +316,10 @@ class Camera2d extends Renderable {
|
|
|
326
316
|
* set the camera to follow the specified renderable. <br>
|
|
327
317
|
* (this will put the camera center around the given target)
|
|
328
318
|
* @name follow
|
|
329
|
-
* @
|
|
319
|
+
* @memberof Camera2d
|
|
330
320
|
* @function
|
|
331
|
-
* @param {
|
|
332
|
-
* @param {
|
|
321
|
+
* @param {Renderable|Vector2d} target renderable or position vector to follow
|
|
322
|
+
* @param {number} [axis=me.game.viewport.AXIS.BOTH] Which axis to follow (see {@link Camera2d.AXIS})
|
|
333
323
|
* @param {number} [damping=1] default damping value
|
|
334
324
|
* @example
|
|
335
325
|
* // set the camera to follow this renderable on both axis, and enable damping
|
|
@@ -368,7 +358,7 @@ class Camera2d extends Renderable {
|
|
|
368
358
|
/**
|
|
369
359
|
* unfollow the current target
|
|
370
360
|
* @name unfollow
|
|
371
|
-
* @
|
|
361
|
+
* @memberof Camera2d
|
|
372
362
|
* @function
|
|
373
363
|
*/
|
|
374
364
|
unfollow() {
|
|
@@ -379,8 +369,8 @@ class Camera2d extends Renderable {
|
|
|
379
369
|
/**
|
|
380
370
|
* move the camera upper-left position by the specified offset.
|
|
381
371
|
* @name move
|
|
382
|
-
* @
|
|
383
|
-
* @see
|
|
372
|
+
* @memberof Camera2d
|
|
373
|
+
* @see Camera2d.focusOn
|
|
384
374
|
* @function
|
|
385
375
|
* @param {number} x
|
|
386
376
|
* @param {number} y
|
|
@@ -395,8 +385,8 @@ class Camera2d extends Renderable {
|
|
|
395
385
|
/**
|
|
396
386
|
* move the camera upper-left position to the specified coordinates
|
|
397
387
|
* @name moveTo
|
|
398
|
-
* @
|
|
399
|
-
* @see
|
|
388
|
+
* @memberof Camera2d
|
|
389
|
+
* @see Camera2d.focusOn
|
|
400
390
|
* @function
|
|
401
391
|
* @param {number} x
|
|
402
392
|
* @param {number} y
|
|
@@ -519,13 +509,12 @@ class Camera2d extends Renderable {
|
|
|
519
509
|
/**
|
|
520
510
|
* shake the camera
|
|
521
511
|
* @name shake
|
|
522
|
-
* @
|
|
512
|
+
* @memberof Camera2d
|
|
523
513
|
* @function
|
|
524
514
|
* @param {number} intensity maximum offset that the screen can be moved
|
|
525
515
|
* while shaking
|
|
526
516
|
* @param {number} duration expressed in milliseconds
|
|
527
|
-
* @param {
|
|
528
|
-
* want the shake effect
|
|
517
|
+
* @param {number} [axis=me.game.viewport.AXIS.BOTH] specify on which axis to apply the shake effect (see {@link Camera2d.AXIS})
|
|
529
518
|
* @param {Function} [onComplete] callback once shaking effect is over
|
|
530
519
|
* @param {boolean} [force] if true this will override the current effect
|
|
531
520
|
* @example
|
|
@@ -545,9 +534,9 @@ class Camera2d extends Renderable {
|
|
|
545
534
|
* fadeOut(flash) effect<p>
|
|
546
535
|
* screen is filled with the specified color and slowly goes back to normal
|
|
547
536
|
* @name fadeOut
|
|
548
|
-
* @
|
|
537
|
+
* @memberof Camera2d
|
|
549
538
|
* @function
|
|
550
|
-
* @param {
|
|
539
|
+
* @param {Color|string} color a CSS color value
|
|
551
540
|
* @param {number} [duration=1000] expressed in milliseconds
|
|
552
541
|
* @param {Function} [onComplete] callback once effect is over
|
|
553
542
|
* @example
|
|
@@ -571,9 +560,9 @@ class Camera2d extends Renderable {
|
|
|
571
560
|
* fadeIn effect <p>
|
|
572
561
|
* fade to the specified color
|
|
573
562
|
* @name fadeIn
|
|
574
|
-
* @
|
|
563
|
+
* @memberof Camera2d
|
|
575
564
|
* @function
|
|
576
|
-
* @param {
|
|
565
|
+
* @param {Color|string} color a CSS color value
|
|
577
566
|
* @param {number} [duration=1000] expressed in milliseconds
|
|
578
567
|
* @param {Function} [onComplete] callback once effect is over
|
|
579
568
|
* @example
|
|
@@ -594,9 +583,9 @@ class Camera2d extends Renderable {
|
|
|
594
583
|
/**
|
|
595
584
|
* set the camera position around the specified object
|
|
596
585
|
* @name focusOn
|
|
597
|
-
* @
|
|
586
|
+
* @memberof Camera2d
|
|
598
587
|
* @function
|
|
599
|
-
* @param {
|
|
588
|
+
* @param {Renderable} target the renderable to focus the camera on
|
|
600
589
|
*/
|
|
601
590
|
focusOn(target) {
|
|
602
591
|
var bounds = target.getBounds();
|
|
@@ -609,9 +598,9 @@ class Camera2d extends Renderable {
|
|
|
609
598
|
/**
|
|
610
599
|
* check if the specified renderable is in the camera
|
|
611
600
|
* @name isVisible
|
|
612
|
-
* @
|
|
601
|
+
* @memberof Camera2d
|
|
613
602
|
* @function
|
|
614
|
-
* @param {
|
|
603
|
+
* @param {Renderable} obj to be checked against
|
|
615
604
|
* @param {boolean} [floating = obj.floating] if visibility check should be done against screen coordinates
|
|
616
605
|
* @returns {boolean}
|
|
617
606
|
*/
|
|
@@ -628,13 +617,13 @@ class Camera2d extends Renderable {
|
|
|
628
617
|
/**
|
|
629
618
|
* convert the given "local" (screen) coordinates into world coordinates
|
|
630
619
|
* @name localToWorld
|
|
631
|
-
* @
|
|
620
|
+
* @memberof Camera2d
|
|
632
621
|
* @function
|
|
633
622
|
* @param {number} x
|
|
634
623
|
* @param {number} y
|
|
635
624
|
* @param {number} [v] an optional vector object where to set the
|
|
636
625
|
* converted value
|
|
637
|
-
* @returns {
|
|
626
|
+
* @returns {Vector2d}
|
|
638
627
|
*/
|
|
639
628
|
localToWorld(x, y, v) {
|
|
640
629
|
// TODO memoization for one set of coords (multitouch)
|
|
@@ -649,13 +638,13 @@ class Camera2d extends Renderable {
|
|
|
649
638
|
/**
|
|
650
639
|
* convert the given world coordinates into "local" (screen) coordinates
|
|
651
640
|
* @name worldToLocal
|
|
652
|
-
* @
|
|
641
|
+
* @memberof Camera2d
|
|
653
642
|
* @function
|
|
654
643
|
* @param {number} x
|
|
655
644
|
* @param {number} y
|
|
656
645
|
* @param {number} [v] an optional vector object where to set the
|
|
657
646
|
* converted value
|
|
658
|
-
* @returns {
|
|
647
|
+
* @returns {Vector2d}
|
|
659
648
|
*/
|
|
660
649
|
worldToLocal(x, y, v) {
|
|
661
650
|
// TODO memoization for one set of coords (multitouch)
|