@vpmedia/phaser 1.0.10 → 1.0.12

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.10",
3
+ "version": "1.0.12",
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",
@@ -32,7 +32,7 @@
32
32
  "husky": "^8.0.2",
33
33
  "jest": "^29.3.1",
34
34
  "lint-staged": "^13.0.3",
35
- "prettier": "^2.7.1",
35
+ "prettier": "^2.8.0",
36
36
  "webpack": "^5.75.0",
37
37
  "webpack-cli": "^4.10.0"
38
38
  },
@@ -68,8 +68,6 @@ export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin
68
68
  export function JSONData(game, json) {
69
69
  // Malformed?
70
70
  if (!json.frames) {
71
- console.warn('AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing frames array');
72
- console.log(json);
73
71
  return null;
74
72
  }
75
73
  // Let's create some frames then
@@ -143,7 +143,14 @@ export default class {
143
143
  isWebGlReady = true;
144
144
  } catch (e) {
145
145
  isWebGlReady = false;
146
- this.exceptionHandler(e);
146
+ const keys = {};
147
+ if (window.PhaserRegistry?.GL_PROGRAM_INFO_LOG) {
148
+ keys.gl_program_log = window.PhaserRegistry.GL_PROGRAM_INFO_LOG;
149
+ }
150
+ if (window.PhaserRegistry?.GL_SHADER_INFO_LOG) {
151
+ keys.gl_shader_log = window.PhaserRegistry.GL_SHADER_INFO_LOG;
152
+ }
153
+ this.exceptionHandler(e, keys);
147
154
  }
148
155
  /*
149
156
  this.renderer = new WebGLRenderer(this);
@@ -219,8 +226,8 @@ export default class {
219
226
  if (config.exceptionHandler) {
220
227
  this.exceptionHandler = config.exceptionHandler;
221
228
  } else {
222
- this.exceptionHandler = (e) => {
223
- console.error(e);
229
+ this.exceptionHandler = (e, keys) => {
230
+ console.error(e, keys);
224
231
  };
225
232
  }
226
233
  if (config.parent) {
@@ -196,12 +196,7 @@ export default class {
196
196
  if (this._sound.stop === undefined) {
197
197
  this._sound.noteOff(0);
198
198
  } else {
199
- try {
200
- this._sound.stop(0);
201
- } catch (e) {
202
- // pass
203
- this.game.exceptionHandler(e);
204
- }
199
+ this._sound.stop(0);
205
200
  }
206
201
  if (this.externalNode) {
207
202
  this._sound.disconnect(this.externalNode);
@@ -383,12 +378,7 @@ export default class {
383
378
  if (this._sound.stop === undefined) {
384
379
  this._sound.noteOff(0);
385
380
  } else {
386
- try {
387
- this._sound.stop(0);
388
- } catch (e) {
389
- // pass
390
- this.game.exceptionHandler(e);
391
- }
381
+ this._sound.stop(0);
392
382
  }
393
383
  if (this.externalNode) {
394
384
  this._sound.disconnect(this.externalNode);
@@ -94,8 +94,11 @@ export default class {
94
94
  if (this.noAudio) {
95
95
  return;
96
96
  }
97
- if (this.context.state === 'suspended') {
98
- this.context.resume();
97
+ const state = this.context.state;
98
+ if (state === 'suspended') {
99
+ this.context.resume().catch((e) => {
100
+ this.game.exceptionHandler(e, { state });
101
+ });
99
102
  }
100
103
  }
101
104
 
@@ -156,17 +159,14 @@ export default class {
156
159
  if (soundData) {
157
160
  if (this.game.cache.isSoundDecoded(key) === false) {
158
161
  this.game.cache.updateSound(key, 'isDecoding', true);
159
- const scope = this;
160
- try {
161
- this.context.decodeAudioData(soundData, (buffer) => {
162
- if (buffer) {
163
- scope.game.cache.decodedSound(key, buffer);
164
- scope.onSoundDecode.dispatch(key, sound);
165
- }
162
+ this.context.decodeAudioData(soundData)
163
+ .then((buffer) => {
164
+ this.game.cache.decodedSound(key, buffer);
165
+ this.onSoundDecode.dispatch(key, sound);
166
+ })
167
+ .catch((e) => {
168
+ this.game.exceptionHandler(e, { key });
166
169
  });
167
- } catch (e) {
168
- scope.game.exceptionHandler(e);
169
- }
170
170
  }
171
171
  }
172
172
  }
@@ -205,7 +205,9 @@ export default class {
205
205
  this._unlockSource = null;
206
206
  this.resumeAudioContext();
207
207
  } else if (this.context.state === 'interrupted') {
208
- this.context.resume();
208
+ this.context.resume().catch((e) => {
209
+ this.game.exceptionHandler(e, { state: this.context.state });
210
+ });
209
211
  }
210
212
  for (let i = 0; i < this._sounds.length; i += 1) {
211
213
  this._sounds[i].update();
@@ -274,11 +274,6 @@ export default class {
274
274
  if (child.visible) {
275
275
  childVisible = true;
276
276
  childBounds = this.children[i].getBounds();
277
- /*
278
- if (isNaN(childBounds.x) && this.children[i].type !== 7) {
279
- console.log(this.children[i]);
280
- }
281
- */
282
277
  minX = (minX < childBounds.x) ? minX : childBounds.x;
283
278
  minY = (minY < childBounds.y) ? minY : childBounds.y;
284
279
  childMaxX = childBounds.width + childBounds.x;
@@ -539,9 +539,7 @@ export function updateGraphics(graphics, gl) {
539
539
  if (data.points.length < stencilBufferLimit * 2) {
540
540
  webGLData = switchMode(webGL, 0);
541
541
  const canDrawUsingSimple = buildPoly(data, webGLData);
542
- // console.log(canDrawUsingSimple);
543
542
  if (!canDrawUsingSimple) {
544
- // console.log("<>>>")
545
543
  webGLData = switchMode(webGL, 1);
546
544
  buildComplexPoly(data, webGLData);
547
545
  }
@@ -27,7 +27,9 @@ export function compileShader(gl, shaderSrc, shaderType) {
27
27
  gl.shaderSource(shader, src);
28
28
  gl.compileShader(shader);
29
29
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
30
- console.log(gl.getShaderInfoLog(shader));
30
+ if (window.PhaserRegistry) {
31
+ window.PhaserRegistry.GL_SHADER_INFO_LOG = gl.getShaderInfoLog(shader);
32
+ }
31
33
  return null;
32
34
  }
33
35
  return shader;
@@ -71,8 +73,9 @@ export function compileProgram(gl, vertexSrc, fragmentSrc) {
71
73
  gl.linkProgram(shaderProgram);
72
74
 
73
75
  if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
74
- console.log(gl.getProgramInfoLog(shaderProgram));
75
- console.log('Could not initialise shaders');
76
+ if (window.PhaserRegistry) {
77
+ window.PhaserRegistry.GL_PROGRAM_INFO_LOG = gl.getProgramInfoLog(shaderProgram);
78
+ }
76
79
  }
77
80
  return shaderProgram;
78
81
  }