@vpmedia/phaser 1.0.26 → 1.0.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/phaser",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
5
5
  "author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "main": "./src/index.js",
19
19
  "devDependencies": {
20
20
  "@babel/cli": "^7.19.3",
21
- "@babel/core": "^7.20.2",
21
+ "@babel/core": "^7.20.5",
22
22
  "@babel/eslint-parser": "^7.19.1",
23
23
  "@babel/preset-env": "^7.20.2",
24
24
  "@babel/register": "^7.18.9",
@@ -17,7 +17,6 @@ export default class {
17
17
  this.windows = false;
18
18
  this.windowsPhone = false;
19
19
  this.canvas = false;
20
- this.pointerLock = false;
21
20
  this.touch = false;
22
21
  this.mspointer = false;
23
22
  this.wheelEvent = null;
@@ -86,14 +86,6 @@ export function checkOS(device) {
86
86
  }
87
87
  }
88
88
 
89
- /**
90
- *
91
- * @param {object} device TBD
92
- */
93
- export function checkFeatures(device) {
94
- device.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document;
95
- }
96
-
97
89
  /**
98
90
  *
99
91
  * @param {object} device TBD
@@ -102,9 +94,9 @@ export function checkInput(device) {
102
94
  if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints >= 1)) {
103
95
  device.touch = true;
104
96
  }
105
- if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) {
106
- device.mspointer = true;
107
- }
97
+ // if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) {
98
+ // device.mspointer = true;
99
+ // }
108
100
  // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel
109
101
  if ('onwheel' in window || 'WheelEvent' in window) {
110
102
  device.wheelEvent = 'wheel';
@@ -269,7 +261,6 @@ export function initialize(device) {
269
261
  checkAudio(device);
270
262
  checkVideo(device);
271
263
  checkDevice(device);
272
- checkFeatures(device);
273
264
  checkFullScreenSupport(device);
274
265
  checkInput(device);
275
266
  }
@@ -73,7 +73,6 @@ export default class {
73
73
  this.enabled = true;
74
74
  this.locked = false;
75
75
  this.stopOnGameOut = false;
76
- this.pointerLock = new Signal();
77
76
  this.event = null;
78
77
  this._onMouseDown = null;
79
78
  this._onMouseMove = null;
@@ -129,9 +128,6 @@ export default class {
129
128
  }
130
129
  window.removeEventListener('mouseup', this._onMouseUpGlobal, true);
131
130
  window.removeEventListener('mouseout', this._onMouseOutGlobal, true);
132
- document.removeEventListener('pointerlockchange', this._pointerLockChange, true);
133
- document.removeEventListener('mozpointerlockchange', this._pointerLockChange, true);
134
- document.removeEventListener('webkitpointerlockchange', this._pointerLockChange, true);
135
131
  }
136
132
 
137
133
  onMouseDown(event) {
@@ -236,41 +232,6 @@ export default class {
236
232
  }
237
233
  }
238
234
 
239
- requestPointerLock() {
240
- if (this.game.device.pointerLock) {
241
- const element = this.game.canvas;
242
- element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock;
243
- element.requestPointerLock();
244
- const scope = this;
245
- this._pointerLockChange = event => scope.pointerLockChange(event);
246
- document.addEventListener('pointerlockchange', this._pointerLockChange, true);
247
- document.addEventListener('mozpointerlockchange', this._pointerLockChange, true);
248
- document.addEventListener('webkitpointerlockchange', this._pointerLockChange, true);
249
- }
250
-
251
- }
252
-
253
- pointerLockChange(event) {
254
- const element = this.game.canvas;
255
- if (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) {
256
- // Pointer was successfully locked
257
- this.locked = true;
258
- this.pointerLock.dispatch(true, event);
259
- } else {
260
- // Pointer was unlocked
261
- this.locked = false;
262
- this.pointerLock.dispatch(false, event);
263
- }
264
- }
265
-
266
- releasePointerLock() {
267
- document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock;
268
- document.exitPointerLock();
269
- document.removeEventListener('pointerlockchange', this._pointerLockChange, true);
270
- document.removeEventListener('mozpointerlockchange', this._pointerLockChange, true);
271
- document.removeEventListener('webkitpointerlockchange', this._pointerLockChange, true);
272
- }
273
-
274
235
  eventPreventDefault(event) {
275
236
  if (this.capture) {
276
237
  if (typeof event.cancelable !== 'boolean' || event.cancelable) {
@@ -540,8 +540,9 @@ export default class {
540
540
  console.warn('Missing loader pack key', pack.key);
541
541
  return;
542
542
  }
543
- for (let i = 0; i < packData.length; i += 1) {
544
- const file = packData[i];
543
+ const packDataCompat = Array.isArray(packData) ? packData : packData.files;
544
+ for (let i = 0; i < packDataCompat.length; i += 1) {
545
+ const file = packDataCompat[i];
545
546
  switch (file.type) {
546
547
  case "image":
547
548
  this.image(file.key, file.url, file.overwrite);
@@ -793,7 +794,7 @@ export default class {
793
794
  if (!reason && xhr) {
794
795
  reason = xhr.status;
795
796
  }
796
- if (reason) {
797
+ if (reason || reason === 0) {
797
798
  message = message + ' (' + reason + ')';
798
799
  }
799
800
  this.asyncComplete(file, message);
@@ -58,8 +58,6 @@ export default class {
58
58
  supportsFullScreen: false,
59
59
  orientationFallback: null,
60
60
  noMargins: false,
61
- scrollTo: null,
62
- forceMinimumDocumentHeight: false,
63
61
  canExpandParent: true,
64
62
  clickTrampoline: '',
65
63
  };
@@ -363,15 +361,7 @@ export default class {
363
361
  this.queueUpdate(true);
364
362
  }
365
363
 
366
- scrollTop() {
367
- const scrollTo = this.compatibility.scrollTo;
368
- if (scrollTo) {
369
- window.scrollTo(scrollTo.x, scrollTo.y);
370
- }
371
- }
372
-
373
364
  refresh() {
374
- this.scrollTop();
375
365
  this.queueUpdate(true);
376
366
  }
377
367
 
@@ -381,12 +371,6 @@ export default class {
381
371
  this.reflowGame();
382
372
  return;
383
373
  }
384
- this.scrollTop();
385
- if (this.compatibility.forceMinimumDocumentHeight) {
386
- // (This came from older code, by why is it here?)
387
- // Set minimum height of content to new window height
388
- document.documentElement.style.minHeight = window.innerHeight + 'px';
389
- }
390
374
  if (this.incorrectOrientation) {
391
375
  this.setMaximum();
392
376
  } else if (scaleMode === SCALE_EXACT_FIT) {
@@ -696,12 +680,6 @@ export default class {
696
680
  this.onFullScreenError.dispatch(this);
697
681
  }
698
682
 
699
- scaleSprite(sprite, width, height, letterBox) {
700
- // TODO
701
- console.warn('scale_manager.scaleSprite() is not implemented');
702
- return sprite;
703
- }
704
-
705
683
  destroy() {
706
684
  this.game.onResume.remove(this._gameResumed, this);
707
685
  window.removeEventListener('orientationchange', this._orientationChange, false);
@@ -8,6 +8,8 @@ import Signal from './signal';
8
8
  export default class {
9
9
 
10
10
  constructor(game, key, volume = 1, loop = false, connect = null) {
11
+ // TODO
12
+ // https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Migrating_from_webkitAudioContext
11
13
  if (!connect) {
12
14
  connect = game.sound.connectToMaster;
13
15
  }
@@ -346,7 +348,7 @@ export default class {
346
348
  const duration = this.duration - (this.pausedPosition / 1000);
347
349
  if (this._sound.start === undefined) {
348
350
  this._sound.noteGrainOn(0, p, duration);
349
- // this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
351
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=457099
350
352
  } else if (this.loop && this.game.device.chrome) {
351
353
  this._sound.start(0, p);
352
354
  } else {
@@ -1,102 +0,0 @@
1
- import Signal from './signal';
2
- /**
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
6
- */
7
-
8
- export default class {
9
-
10
- constructor(parent, buttonCode) {
11
- this.parent = parent;
12
- this.game = parent.game;
13
- this.event = null;
14
- this.isDown = false;
15
- this.isUp = true;
16
- this.timeDown = 0;
17
- this.timeUp = 0;
18
- this.repeats = 0;
19
- this.altKey = false;
20
- this.shiftKey = false;
21
- this.ctrlKey = false;
22
- this.value = 0;
23
- this.buttonCode = buttonCode;
24
- this.onDown = new Signal();
25
- this.onUp = new Signal();
26
- this.onFloat = new Signal();
27
- }
28
-
29
- start(event, value) {
30
- if (this.isDown) {
31
- return;
32
- }
33
- this.isDown = true;
34
- this.isUp = false;
35
- this.timeDown = this.game.time.time;
36
- this.repeats = 0;
37
- this.event = event;
38
- this.value = value;
39
- if (event) {
40
- this.altKey = event.altKey;
41
- this.shiftKey = event.shiftKey;
42
- this.ctrlKey = event.ctrlKey;
43
- }
44
- this.onDown.dispatch(this, value);
45
- }
46
-
47
- stop(event, value) {
48
- if (this.isUp) {
49
- return;
50
- }
51
- this.isDown = false;
52
- this.isUp = true;
53
- this.timeUp = this.game.time.time;
54
- this.event = event;
55
- this.value = value;
56
- if (event) {
57
- this.altKey = event.altKey;
58
- this.shiftKey = event.shiftKey;
59
- this.ctrlKey = event.ctrlKey;
60
- }
61
- this.onUp.dispatch(this, value);
62
- }
63
-
64
- padFloat(value) {
65
- this.value = value;
66
- this.onFloat.dispatch(this, value);
67
- }
68
-
69
- justPressed(duration = 250) {
70
- return (this.isDown && (this.timeDown + duration) > this.game.time.time);
71
- }
72
-
73
- justReleased(duration = 250) {
74
- return (this.isUp && (this.timeUp + duration) > this.game.time.time);
75
- }
76
-
77
- reset() {
78
- this.isDown = false;
79
- this.isUp = true;
80
- this.timeDown = this.game.time.time;
81
- this.repeats = 0;
82
- this.altKey = false;
83
- this.shiftKey = false;
84
- this.ctrlKey = false;
85
- }
86
-
87
- destroy() {
88
- this.onDown.dispose();
89
- this.onUp.dispose();
90
- this.onFloat.dispose();
91
- this.parent = null;
92
- this.game = null;
93
- }
94
-
95
- get duration() {
96
- if (this.isUp) {
97
- return -1;
98
- }
99
- return this.game.time.time - this.timeDown;
100
- }
101
-
102
- }