melonjs 10.3.0 → 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 +2419 -3072
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +3417 -3816
- package/dist/melonjs.module.js +2737 -3002
- package/package.json +16 -16
- package/src/audio/audio.js +29 -30
- package/src/camera/camera2d.js +46 -56
- package/src/entity/draggable.js +12 -13
- package/src/entity/droptarget.js +13 -15
- package/src/entity/entity.js +30 -36
- package/src/game.js +21 -22
- package/src/geometries/ellipse.js +40 -46
- package/src/geometries/line.js +9 -11
- package/src/geometries/poly.js +53 -53
- package/src/geometries/rectangle.js +42 -44
- package/src/index.js +4 -14
- 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 +30 -31
- package/src/input/pointerevent.js +26 -26
- package/src/lang/deprecated.js +25 -6
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -8
- package/src/level/tiled/TMXLayer.js +30 -32
- package/src/level/tiled/TMXObject.js +21 -21
- package/src/level/tiled/TMXTile.js +18 -18
- package/src/level/tiled/TMXTileMap.js +37 -44
- package/src/level/tiled/TMXTileset.js +12 -15
- package/src/level/tiled/TMXTilesetGroup.js +9 -9
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
- package/src/level/tiled/renderer/TMXRenderer.js +24 -25
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
- package/src/loader/loader.js +14 -15
- package/src/loader/loadingscreen.js +2 -4
- package/src/math/color.js +47 -66
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -58
- package/src/math/matrix3.js +56 -62
- package/src/math/observable_vector2.js +75 -76
- package/src/math/observable_vector3.js +79 -80
- package/src/math/vector2.js +91 -92
- package/src/math/vector3.js +94 -96
- package/src/particles/emitter.js +38 -40
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +44 -142
- package/src/physics/bounds.js +47 -47
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +14 -14
- package/src/physics/quadtree.js +17 -19
- package/src/physics/sat.js +26 -26
- package/src/physics/world.js +24 -28
- package/src/plugin/plugin.js +11 -14
- package/src/renderable/GUI.js +41 -46
- package/src/renderable/collectable.js +4 -8
- package/src/renderable/colorlayer.js +6 -10
- package/src/renderable/container.js +87 -72
- package/src/renderable/imagelayer.js +25 -31
- package/src/renderable/nineslicesprite.js +41 -41
- package/src/renderable/renderable.js +112 -122
- package/src/renderable/sprite.js +62 -68
- package/src/renderable/trigger.js +25 -30
- package/src/state/stage.js +13 -17
- package/src/state/state.js +26 -27
- package/src/system/device.js +74 -75
- package/src/system/event.js +71 -72
- 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 -54
- package/src/text/bitmaptextdata.js +10 -10
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +44 -49
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +43 -44
- 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 +58 -59
- package/src/video/renderer.js +49 -53
- package/src/video/texture.js +98 -111
- package/src/video/texture_cache.js +2 -2
- package/src/video/video.js +15 -16
- package/src/video/webgl/glshader.js +37 -38
- package/src/video/webgl/webgl_compositor.js +31 -32
- package/src/video/webgl/webgl_renderer.js +79 -80
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.
|
|
62
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
63
63
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
64
|
-
"@rollup/plugin-replace": "^
|
|
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.7
|
|
69
|
-
"jasmine-core": "^4.0.
|
|
67
|
+
"eslint": "^8.10.0",
|
|
68
|
+
"eslint-plugin-jsdoc": "^37.9.7",
|
|
69
|
+
"jasmine-core": "^4.0.1",
|
|
70
70
|
"jsdoc": "^3.6.10",
|
|
71
|
-
"karma": "^6.3.
|
|
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
77
|
"qs": "^6.10.3",
|
|
78
|
-
"rollup": "^2.
|
|
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
|
-
* @memberof
|
|
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,7 +238,7 @@ 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
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.
|
|
@@ -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
|
@@ -21,33 +21,28 @@ var targetV = new Vector2d();
|
|
|
21
21
|
/**
|
|
22
22
|
* @classdesc
|
|
23
23
|
* a 2D orthographic camera
|
|
24
|
-
* @
|
|
25
|
-
* @augments me.Renderable
|
|
26
|
-
* @memberof me
|
|
27
|
-
* @param {number} minX start x offset
|
|
28
|
-
* @param {number} minY start y offset
|
|
29
|
-
* @param {number} maxX end x offset
|
|
30
|
-
* @param {number} maxY end y offset
|
|
24
|
+
* @augments Renderable
|
|
31
25
|
*/
|
|
32
26
|
class Camera2d extends Renderable {
|
|
33
|
-
|
|
34
27
|
/**
|
|
35
|
-
* @
|
|
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
|
|
36
32
|
*/
|
|
37
33
|
constructor(minX, minY, maxX, maxY) {
|
|
38
34
|
super(minX, minY, maxX - minX, maxY - minY);
|
|
39
35
|
|
|
40
36
|
/**
|
|
41
37
|
* Axis definition
|
|
38
|
+
* @enum {number}
|
|
42
39
|
* @property {number} NONE no axis
|
|
43
40
|
* @property {number} HORIZONTAL horizontal axis only
|
|
44
41
|
* @property {number} VERTICAL vertical axis only
|
|
45
42
|
* @property {number} BOTH both axis
|
|
46
|
-
* @
|
|
47
|
-
* @constant
|
|
48
|
-
* @enum {number}
|
|
43
|
+
* @readonly
|
|
49
44
|
* @name AXIS
|
|
50
|
-
* @memberof
|
|
45
|
+
* @memberof Camera2d
|
|
51
46
|
*/
|
|
52
47
|
this.AXIS = {
|
|
53
48
|
NONE : 0,
|
|
@@ -59,20 +54,16 @@ class Camera2d extends Renderable {
|
|
|
59
54
|
/**
|
|
60
55
|
* Camera bounds
|
|
61
56
|
* @public
|
|
62
|
-
* @type {
|
|
57
|
+
* @type {Bounds}
|
|
63
58
|
* @name bounds
|
|
64
|
-
* @memberof
|
|
59
|
+
* @memberof Camera2d
|
|
65
60
|
*/
|
|
66
61
|
this.bounds = pool.pull("Bounds");
|
|
67
62
|
|
|
68
63
|
/**
|
|
69
|
-
*
|
|
64
|
+
* enable or disable damping
|
|
70
65
|
* @private
|
|
71
|
-
* @type {boolean}
|
|
72
|
-
* @name smoothFollow
|
|
73
|
-
* @see me.Camera2d.damping
|
|
74
66
|
* @default true
|
|
75
|
-
* @memberof me.Camera2d
|
|
76
67
|
*/
|
|
77
68
|
this.smoothFollow = true;
|
|
78
69
|
|
|
@@ -83,7 +74,7 @@ class Camera2d extends Renderable {
|
|
|
83
74
|
* @type {number}
|
|
84
75
|
* @name damping
|
|
85
76
|
* @default 1.0
|
|
86
|
-
* @memberof
|
|
77
|
+
* @memberof Camera2d
|
|
87
78
|
*/
|
|
88
79
|
this.damping = 1.0;
|
|
89
80
|
|
|
@@ -93,7 +84,7 @@ class Camera2d extends Renderable {
|
|
|
93
84
|
* @type {number}
|
|
94
85
|
* @name near
|
|
95
86
|
* @default -1000
|
|
96
|
-
* @memberof
|
|
87
|
+
* @memberof Camera2d
|
|
97
88
|
*/
|
|
98
89
|
this.near = -1000;
|
|
99
90
|
|
|
@@ -103,7 +94,7 @@ class Camera2d extends Renderable {
|
|
|
103
94
|
* @type {number}
|
|
104
95
|
* @name far
|
|
105
96
|
* @default 1000
|
|
106
|
-
* @memberof
|
|
97
|
+
* @memberof Camera2d
|
|
107
98
|
*/
|
|
108
99
|
this.far = 1000;
|
|
109
100
|
|
|
@@ -111,18 +102,18 @@ class Camera2d extends Renderable {
|
|
|
111
102
|
* the default camera projection matrix
|
|
112
103
|
* (2d cameras use an orthographic projection by default).
|
|
113
104
|
* @public
|
|
114
|
-
* @type {
|
|
105
|
+
* @type {Matrix3d}
|
|
115
106
|
* @name projectionMatrix
|
|
116
|
-
* @memberof
|
|
107
|
+
* @memberof Camera2d
|
|
117
108
|
*/
|
|
118
109
|
this.projectionMatrix = new Matrix3d();
|
|
119
110
|
|
|
120
111
|
/**
|
|
121
112
|
* the invert camera transform used to unproject points
|
|
122
113
|
* @ignore
|
|
123
|
-
* @type {
|
|
114
|
+
* @type {Matrix2d}
|
|
124
115
|
* @name invCurrentTransform
|
|
125
|
-
* @memberof
|
|
116
|
+
* @memberof Camera2d
|
|
126
117
|
*/
|
|
127
118
|
this.invCurrentTransform = new Matrix2d();
|
|
128
119
|
|
|
@@ -215,7 +206,7 @@ class Camera2d extends Renderable {
|
|
|
215
206
|
/**
|
|
216
207
|
* reset the camera position to specified coordinates
|
|
217
208
|
* @name reset
|
|
218
|
-
* @memberof
|
|
209
|
+
* @memberof Camera2d
|
|
219
210
|
* @function
|
|
220
211
|
* @param {number} [x=0]
|
|
221
212
|
* @param {number} [y=0]
|
|
@@ -245,8 +236,8 @@ class Camera2d extends Renderable {
|
|
|
245
236
|
* the "deadzone" defines an area within the current camera in which
|
|
246
237
|
* the followed renderable can move without scrolling the camera.
|
|
247
238
|
* @name setDeadzone
|
|
248
|
-
* @see
|
|
249
|
-
* @memberof
|
|
239
|
+
* @see Camera2d.follow
|
|
240
|
+
* @memberof Camera2d
|
|
250
241
|
* @function
|
|
251
242
|
* @param {number} w deadzone width
|
|
252
243
|
* @param {number} h deadzone height
|
|
@@ -274,11 +265,11 @@ class Camera2d extends Renderable {
|
|
|
274
265
|
/**
|
|
275
266
|
* resize the camera
|
|
276
267
|
* @name resize
|
|
277
|
-
* @memberof
|
|
268
|
+
* @memberof Camera2d
|
|
278
269
|
* @function
|
|
279
270
|
* @param {number} w new width of the camera
|
|
280
271
|
* @param {number} h new height of the camera
|
|
281
|
-
* @returns {
|
|
272
|
+
* @returns {Camera2d} this camera
|
|
282
273
|
*/
|
|
283
274
|
resize(w, h) {
|
|
284
275
|
// parent consctructor, resize camera rect
|
|
@@ -306,7 +297,7 @@ class Camera2d extends Renderable {
|
|
|
306
297
|
* set the camera boundaries (set to the world limit by default).
|
|
307
298
|
* the camera is bound to the given coordinates and cannot move/be scrolled outside of it.
|
|
308
299
|
* @name setBounds
|
|
309
|
-
* @memberof
|
|
300
|
+
* @memberof Camera2d
|
|
310
301
|
* @function
|
|
311
302
|
* @param {number} x world left limit
|
|
312
303
|
* @param {number} y world top limit
|
|
@@ -325,10 +316,10 @@ class Camera2d extends Renderable {
|
|
|
325
316
|
* set the camera to follow the specified renderable. <br>
|
|
326
317
|
* (this will put the camera center around the given target)
|
|
327
318
|
* @name follow
|
|
328
|
-
* @memberof
|
|
319
|
+
* @memberof Camera2d
|
|
329
320
|
* @function
|
|
330
|
-
* @param {
|
|
331
|
-
* @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})
|
|
332
323
|
* @param {number} [damping=1] default damping value
|
|
333
324
|
* @example
|
|
334
325
|
* // set the camera to follow this renderable on both axis, and enable damping
|
|
@@ -367,7 +358,7 @@ class Camera2d extends Renderable {
|
|
|
367
358
|
/**
|
|
368
359
|
* unfollow the current target
|
|
369
360
|
* @name unfollow
|
|
370
|
-
* @memberof
|
|
361
|
+
* @memberof Camera2d
|
|
371
362
|
* @function
|
|
372
363
|
*/
|
|
373
364
|
unfollow() {
|
|
@@ -378,8 +369,8 @@ class Camera2d extends Renderable {
|
|
|
378
369
|
/**
|
|
379
370
|
* move the camera upper-left position by the specified offset.
|
|
380
371
|
* @name move
|
|
381
|
-
* @memberof
|
|
382
|
-
* @see
|
|
372
|
+
* @memberof Camera2d
|
|
373
|
+
* @see Camera2d.focusOn
|
|
383
374
|
* @function
|
|
384
375
|
* @param {number} x
|
|
385
376
|
* @param {number} y
|
|
@@ -394,8 +385,8 @@ class Camera2d extends Renderable {
|
|
|
394
385
|
/**
|
|
395
386
|
* move the camera upper-left position to the specified coordinates
|
|
396
387
|
* @name moveTo
|
|
397
|
-
* @memberof
|
|
398
|
-
* @see
|
|
388
|
+
* @memberof Camera2d
|
|
389
|
+
* @see Camera2d.focusOn
|
|
399
390
|
* @function
|
|
400
391
|
* @param {number} x
|
|
401
392
|
* @param {number} y
|
|
@@ -518,13 +509,12 @@ class Camera2d extends Renderable {
|
|
|
518
509
|
/**
|
|
519
510
|
* shake the camera
|
|
520
511
|
* @name shake
|
|
521
|
-
* @memberof
|
|
512
|
+
* @memberof Camera2d
|
|
522
513
|
* @function
|
|
523
514
|
* @param {number} intensity maximum offset that the screen can be moved
|
|
524
515
|
* while shaking
|
|
525
516
|
* @param {number} duration expressed in milliseconds
|
|
526
|
-
* @param {
|
|
527
|
-
* 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})
|
|
528
518
|
* @param {Function} [onComplete] callback once shaking effect is over
|
|
529
519
|
* @param {boolean} [force] if true this will override the current effect
|
|
530
520
|
* @example
|
|
@@ -544,9 +534,9 @@ class Camera2d extends Renderable {
|
|
|
544
534
|
* fadeOut(flash) effect<p>
|
|
545
535
|
* screen is filled with the specified color and slowly goes back to normal
|
|
546
536
|
* @name fadeOut
|
|
547
|
-
* @memberof
|
|
537
|
+
* @memberof Camera2d
|
|
548
538
|
* @function
|
|
549
|
-
* @param {
|
|
539
|
+
* @param {Color|string} color a CSS color value
|
|
550
540
|
* @param {number} [duration=1000] expressed in milliseconds
|
|
551
541
|
* @param {Function} [onComplete] callback once effect is over
|
|
552
542
|
* @example
|
|
@@ -570,9 +560,9 @@ class Camera2d extends Renderable {
|
|
|
570
560
|
* fadeIn effect <p>
|
|
571
561
|
* fade to the specified color
|
|
572
562
|
* @name fadeIn
|
|
573
|
-
* @memberof
|
|
563
|
+
* @memberof Camera2d
|
|
574
564
|
* @function
|
|
575
|
-
* @param {
|
|
565
|
+
* @param {Color|string} color a CSS color value
|
|
576
566
|
* @param {number} [duration=1000] expressed in milliseconds
|
|
577
567
|
* @param {Function} [onComplete] callback once effect is over
|
|
578
568
|
* @example
|
|
@@ -593,9 +583,9 @@ class Camera2d extends Renderable {
|
|
|
593
583
|
/**
|
|
594
584
|
* set the camera position around the specified object
|
|
595
585
|
* @name focusOn
|
|
596
|
-
* @memberof
|
|
586
|
+
* @memberof Camera2d
|
|
597
587
|
* @function
|
|
598
|
-
* @param {
|
|
588
|
+
* @param {Renderable} target the renderable to focus the camera on
|
|
599
589
|
*/
|
|
600
590
|
focusOn(target) {
|
|
601
591
|
var bounds = target.getBounds();
|
|
@@ -608,9 +598,9 @@ class Camera2d extends Renderable {
|
|
|
608
598
|
/**
|
|
609
599
|
* check if the specified renderable is in the camera
|
|
610
600
|
* @name isVisible
|
|
611
|
-
* @memberof
|
|
601
|
+
* @memberof Camera2d
|
|
612
602
|
* @function
|
|
613
|
-
* @param {
|
|
603
|
+
* @param {Renderable} obj to be checked against
|
|
614
604
|
* @param {boolean} [floating = obj.floating] if visibility check should be done against screen coordinates
|
|
615
605
|
* @returns {boolean}
|
|
616
606
|
*/
|
|
@@ -627,13 +617,13 @@ class Camera2d extends Renderable {
|
|
|
627
617
|
/**
|
|
628
618
|
* convert the given "local" (screen) coordinates into world coordinates
|
|
629
619
|
* @name localToWorld
|
|
630
|
-
* @memberof
|
|
620
|
+
* @memberof Camera2d
|
|
631
621
|
* @function
|
|
632
622
|
* @param {number} x
|
|
633
623
|
* @param {number} y
|
|
634
624
|
* @param {number} [v] an optional vector object where to set the
|
|
635
625
|
* converted value
|
|
636
|
-
* @returns {
|
|
626
|
+
* @returns {Vector2d}
|
|
637
627
|
*/
|
|
638
628
|
localToWorld(x, y, v) {
|
|
639
629
|
// TODO memoization for one set of coords (multitouch)
|
|
@@ -648,13 +638,13 @@ class Camera2d extends Renderable {
|
|
|
648
638
|
/**
|
|
649
639
|
* convert the given world coordinates into "local" (screen) coordinates
|
|
650
640
|
* @name worldToLocal
|
|
651
|
-
* @memberof
|
|
641
|
+
* @memberof Camera2d
|
|
652
642
|
* @function
|
|
653
643
|
* @param {number} x
|
|
654
644
|
* @param {number} y
|
|
655
645
|
* @param {number} [v] an optional vector object where to set the
|
|
656
646
|
* converted value
|
|
657
|
-
* @returns {
|
|
647
|
+
* @returns {Vector2d}
|
|
658
648
|
*/
|
|
659
649
|
worldToLocal(x, y, v) {
|
|
660
650
|
// TODO memoization for one set of coords (multitouch)
|
package/src/entity/draggable.js
CHANGED
|
@@ -6,15 +6,14 @@ import Entity from "./entity.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* @classdesc
|
|
8
8
|
* Used to make a game entity draggable
|
|
9
|
-
* @
|
|
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})
|
|
9
|
+
* @augments Entity
|
|
15
10
|
*/
|
|
16
11
|
class DraggableEntity extends Entity {
|
|
17
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @param {number} x the x coordinates of the entity object
|
|
14
|
+
* @param {number} y the y coordinates of the entity object
|
|
15
|
+
* @param {object} settings Entity properties (see {@link Entity})
|
|
16
|
+
*/
|
|
18
17
|
constructor(x, y, settings) {
|
|
19
18
|
super(x, y, settings);
|
|
20
19
|
this.dragging = false;
|
|
@@ -32,7 +31,7 @@ class DraggableEntity extends Entity {
|
|
|
32
31
|
* this module testable. Then we subscribe this module to the
|
|
33
32
|
* transformed events.
|
|
34
33
|
* @name initEvents
|
|
35
|
-
* @memberof
|
|
34
|
+
* @memberof DraggableEntity
|
|
36
35
|
* @function
|
|
37
36
|
*/
|
|
38
37
|
initEvents() {
|
|
@@ -59,7 +58,7 @@ class DraggableEntity extends Entity {
|
|
|
59
58
|
/**
|
|
60
59
|
* Translates a pointer event to a me.event
|
|
61
60
|
* @name translatePointerEvent
|
|
62
|
-
* @memberof
|
|
61
|
+
* @memberof DraggableEntity
|
|
63
62
|
* @function
|
|
64
63
|
* @param {object} e the pointer event you want to translate
|
|
65
64
|
* @param {string} translation the me.event you want to translate the event to
|
|
@@ -71,7 +70,7 @@ class DraggableEntity extends Entity {
|
|
|
71
70
|
/**
|
|
72
71
|
* Gets called when the user starts dragging the entity
|
|
73
72
|
* @name dragStart
|
|
74
|
-
* @memberof
|
|
73
|
+
* @memberof DraggableEntity
|
|
75
74
|
* @function
|
|
76
75
|
* @param {object} e the pointer event
|
|
77
76
|
* @returns {boolean} false if the object is being dragged
|
|
@@ -88,7 +87,7 @@ class DraggableEntity extends Entity {
|
|
|
88
87
|
/**
|
|
89
88
|
* Gets called when the user drags this entity around
|
|
90
89
|
* @name dragMove
|
|
91
|
-
* @memberof
|
|
90
|
+
* @memberof DraggableEntity
|
|
92
91
|
* @function
|
|
93
92
|
* @param {object} e the pointer event
|
|
94
93
|
*/
|
|
@@ -102,7 +101,7 @@ class DraggableEntity extends Entity {
|
|
|
102
101
|
/**
|
|
103
102
|
* Gets called when the user stops dragging the entity
|
|
104
103
|
* @name dragEnd
|
|
105
|
-
* @memberof
|
|
104
|
+
* @memberof DraggableEntity
|
|
106
105
|
* @function
|
|
107
106
|
* @returns {boolean} false if the object stopped being dragged
|
|
108
107
|
*/
|
|
@@ -116,7 +115,7 @@ class DraggableEntity extends Entity {
|
|
|
116
115
|
/**
|
|
117
116
|
* Destructor
|
|
118
117
|
* @name destroy
|
|
119
|
-
* @memberof
|
|
118
|
+
* @memberof DraggableEntity
|
|
120
119
|
* @function
|
|
121
120
|
*/
|
|
122
121
|
destroy() {
|