@vpmedia/phaser 1.0.11 → 1.0.13
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 +1 -1
- package/dist/phaser.cjs +1 -1
- package/dist/phaser.cjs.LICENSE.txt +1 -1
- package/dist/phaser.cjs.map +1 -1
- package/dist/phaser.js +1 -1
- package/dist/phaser.js.LICENSE.txt +1 -1
- package/dist/phaser.js.map +1 -1
- package/package.json +2 -2
- package/src/phaser/core/animation_parser.js +0 -2
- package/src/phaser/core/const.js +0 -1
- package/src/phaser/core/device.js +0 -7
- package/src/phaser/core/device_util.js +7 -33
- package/src/phaser/core/game.js +15 -13
- package/src/phaser/core/scale_manager.js +0 -10
- package/src/phaser/core/sound.js +3 -18
- package/src/phaser/core/sound_manager.js +9 -4
- package/src/phaser/display/display_object.js +0 -5
- package/src/phaser/display/webgl/graphics.js +0 -2
- package/src/phaser/display/webgl/util.js +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
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.
|
|
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
|
package/src/phaser/core/const.js
CHANGED
|
@@ -58,7 +58,6 @@ export const BLEND_LUMINOSITY = 16;
|
|
|
58
58
|
export const RENDER_AUTO = 0;
|
|
59
59
|
export const RENDER_CANVAS = 1;
|
|
60
60
|
export const RENDER_WEBGL = 2;
|
|
61
|
-
export const RENDER_HEADLESS = 3;
|
|
62
61
|
// pointer modes
|
|
63
62
|
export const POINTER_CURSOR = 1;
|
|
64
63
|
export const POINTER_CONTACT = 2;
|
|
@@ -10,8 +10,6 @@ export default class {
|
|
|
10
10
|
this.deviceReadyAt = 0;
|
|
11
11
|
this.desktop = false;
|
|
12
12
|
this.iOS = false;
|
|
13
|
-
this.iOSVersion = 0;
|
|
14
|
-
this.node = false;
|
|
15
13
|
this.android = false;
|
|
16
14
|
this.chromeOS = false;
|
|
17
15
|
this.linux = false;
|
|
@@ -24,14 +22,9 @@ export default class {
|
|
|
24
22
|
this.mspointer = false;
|
|
25
23
|
this.wheelEvent = null;
|
|
26
24
|
this.chrome = false;
|
|
27
|
-
this.chromeVersion = 0;
|
|
28
25
|
this.firefox = false;
|
|
29
|
-
this.firefoxVersion = 0;
|
|
30
26
|
this.edge = false;
|
|
31
|
-
this.mobileSafari = false;
|
|
32
27
|
this.safari = false;
|
|
33
|
-
this.safariVersion = 0;
|
|
34
|
-
this.webApp = false;
|
|
35
28
|
this.silk = false;
|
|
36
29
|
this.ogg = false;
|
|
37
30
|
this.opus = false;
|
|
@@ -60,12 +60,12 @@ export function checkOS(device) {
|
|
|
60
60
|
device.chromeOS = true;
|
|
61
61
|
} else if (/iP[ao]d|iPhone/i.test(ua)) {
|
|
62
62
|
device.iOS = true;
|
|
63
|
-
|
|
64
|
-
device.
|
|
65
|
-
} else if (/Linux/.test(ua)) {
|
|
66
|
-
device.linux = true;
|
|
63
|
+
} else if (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) {
|
|
64
|
+
device.iOS = true;
|
|
67
65
|
} else if (/Mac OS/.test(ua)) {
|
|
68
66
|
device.macOS = true;
|
|
67
|
+
} else if (/Linux/.test(ua)) {
|
|
68
|
+
device.linux = true;
|
|
69
69
|
} else if (/Windows/.test(ua)) {
|
|
70
70
|
device.windows = true;
|
|
71
71
|
}
|
|
@@ -80,12 +80,8 @@ export function checkOS(device) {
|
|
|
80
80
|
if (device.windows || device.macOS || (device.linux && !silk) || device.chromeOS) {
|
|
81
81
|
device.desktop = true;
|
|
82
82
|
}
|
|
83
|
-
//
|
|
84
|
-
if (device.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) {
|
|
85
|
-
device.desktop = false;
|
|
86
|
-
}
|
|
87
|
-
// VPMedia Special override
|
|
88
|
-
if (window.location.pathname.indexOf('/mobile/') > -1) {
|
|
83
|
+
// iOS / Windows Phone / Tablet reset
|
|
84
|
+
if (device.android || device.iOS || device.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) {
|
|
89
85
|
device.desktop = false;
|
|
90
86
|
}
|
|
91
87
|
}
|
|
@@ -171,29 +167,15 @@ export function checkBrowser(device) {
|
|
|
171
167
|
device.edge = true;
|
|
172
168
|
} else if (/Chrome\/(\d+)/.test(ua) && !device.windowsPhone) {
|
|
173
169
|
device.chrome = true;
|
|
174
|
-
device.chromeVersion = parseInt(RegExp.$1, 10);
|
|
175
170
|
} else if (/Firefox\D+(\d+)/.test(ua)) {
|
|
176
171
|
device.firefox = true;
|
|
177
|
-
device.firefoxVersion = parseInt(RegExp.$1, 10);
|
|
178
|
-
} else if (/AppleWebKit/.test(ua) && device.iOS) {
|
|
179
|
-
device.mobileSafari = true;
|
|
180
172
|
} else if (/Safari\/(\d+)/.test(ua) && !device.windowsPhone) {
|
|
181
173
|
device.safari = true;
|
|
182
|
-
if (/Version\/(\d+)\./.test(ua)) {
|
|
183
|
-
device.safariVersion = parseInt(RegExp.$1, 10);
|
|
184
|
-
}
|
|
185
174
|
}
|
|
186
175
|
// Silk gets its own if clause because its ua also contains 'Safari'
|
|
187
176
|
if (/Silk/.test(ua)) {
|
|
188
177
|
device.silk = true;
|
|
189
178
|
}
|
|
190
|
-
// WebApp mode in iOS
|
|
191
|
-
if (navigator.standalone) {
|
|
192
|
-
device.webApp = true;
|
|
193
|
-
}
|
|
194
|
-
if (typeof process !== 'undefined' && typeof require !== 'undefined') {
|
|
195
|
-
device.node = true;
|
|
196
|
-
}
|
|
197
179
|
}
|
|
198
180
|
|
|
199
181
|
/**
|
|
@@ -257,16 +239,8 @@ export function checkAudio(device) {
|
|
|
257
239
|
device.webm = true;
|
|
258
240
|
}
|
|
259
241
|
if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') {
|
|
260
|
-
if (device.edge) {
|
|
242
|
+
if (device.edge || device.safari) {
|
|
261
243
|
device.dolby = true;
|
|
262
|
-
} else if (device.safari && device.safariVersion >= 9) {
|
|
263
|
-
if (/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)) {
|
|
264
|
-
const major = parseInt(RegExp.$1, 10);
|
|
265
|
-
const minor = parseInt(RegExp.$2, 10);
|
|
266
|
-
if ((major === 10 && minor >= 11) || major > 10) {
|
|
267
|
-
device.dolby = true;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
244
|
}
|
|
271
245
|
}
|
|
272
246
|
}
|
package/src/phaser/core/game.js
CHANGED
|
@@ -20,7 +20,7 @@ import Time from './time';
|
|
|
20
20
|
import TweenManager from './tween_manager';
|
|
21
21
|
import World from './world';
|
|
22
22
|
import Stage from './stage';
|
|
23
|
-
import { RENDER_AUTO, RENDER_WEBGL
|
|
23
|
+
import { RENDER_AUTO, RENDER_WEBGL } from './const';
|
|
24
24
|
import { create, removeFromDOM, addToDOM, setTouchAction } from '../display/canvas/util';
|
|
25
25
|
import { initialize, checkOS } from './device_util';
|
|
26
26
|
|
|
@@ -143,7 +143,14 @@ export default class {
|
|
|
143
143
|
isWebGlReady = true;
|
|
144
144
|
} catch (e) {
|
|
145
145
|
isWebGlReady = false;
|
|
146
|
-
|
|
146
|
+
const tags = {};
|
|
147
|
+
if (window.PhaserRegistry?.GL_PROGRAM_INFO_LOG) {
|
|
148
|
+
tags.gl_program_log = window.PhaserRegistry.GL_PROGRAM_INFO_LOG;
|
|
149
|
+
}
|
|
150
|
+
if (window.PhaserRegistry?.GL_SHADER_INFO_LOG) {
|
|
151
|
+
tags.gl_shader_log = window.PhaserRegistry.GL_SHADER_INFO_LOG;
|
|
152
|
+
}
|
|
153
|
+
this.exceptionHandler(e, tags);
|
|
147
154
|
}
|
|
148
155
|
/*
|
|
149
156
|
this.renderer = new WebGLRenderer(this);
|
|
@@ -168,11 +175,9 @@ export default class {
|
|
|
168
175
|
this.renderer = new CanvasRenderer(this);
|
|
169
176
|
this.context = this.renderer.context;
|
|
170
177
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
setTouchAction(this.canvas);
|
|
175
|
-
}
|
|
178
|
+
this.stage.smoothed = this.config.antialias;
|
|
179
|
+
addToDOM(this.canvas, this.parent, false);
|
|
180
|
+
setTouchAction(this.canvas);
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
parseConfigElement(config, key, defaultValue) {
|
|
@@ -209,7 +214,7 @@ export default class {
|
|
|
209
214
|
// Clear the Canvas each frame before rendering the display list.
|
|
210
215
|
// You can set this to `false` to gain some performance if your game always contains a background that completely fills the display.
|
|
211
216
|
this.parseConfigElement(config, 'clearBeforeRender', true);
|
|
212
|
-
// The Renderer this game will use. Either PowerGamer.Const.RENDER_AUTO, PowerGamer.Const.RENDER_CANVAS, PowerGamer.Const.RENDER_WEBGL
|
|
217
|
+
// The Renderer this game will use. Either PowerGamer.Const.RENDER_AUTO, PowerGamer.Const.RENDER_CANVAS, PowerGamer.Const.RENDER_WEBGL
|
|
213
218
|
this.parseConfigElement(config, 'renderType', RENDER_AUTO);
|
|
214
219
|
// Force audio disabled
|
|
215
220
|
this.parseConfigElement(config, 'isForceDisabledAudio', false);
|
|
@@ -219,8 +224,8 @@ export default class {
|
|
|
219
224
|
if (config.exceptionHandler) {
|
|
220
225
|
this.exceptionHandler = config.exceptionHandler;
|
|
221
226
|
} else {
|
|
222
|
-
this.exceptionHandler = (e) => {
|
|
223
|
-
console.error(e);
|
|
227
|
+
this.exceptionHandler = (e, tags) => {
|
|
228
|
+
console.error(e, tags);
|
|
224
229
|
};
|
|
225
230
|
}
|
|
226
231
|
if (config.parent) {
|
|
@@ -339,9 +344,6 @@ export default class {
|
|
|
339
344
|
return;
|
|
340
345
|
}
|
|
341
346
|
this.state.preRender(elapsedTime);
|
|
342
|
-
if (this.config.renderType === RENDER_HEADLESS) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
347
|
this.renderer.render(this.stage);
|
|
346
348
|
this.state.render(elapsedTime);
|
|
347
349
|
}
|
|
@@ -95,16 +95,6 @@ export default class {
|
|
|
95
95
|
// Configure device-dependent compatibility
|
|
96
96
|
const compat = this.compatibility;
|
|
97
97
|
compat.supportsFullScreen = this.game.device.fullscreen;
|
|
98
|
-
// We can't do anything about the status bars in iPads, web apps or desktops
|
|
99
|
-
/*
|
|
100
|
-
if (!this.game.device.iPad && !this.game.device.webApp && !this.game.device.desktop) {
|
|
101
|
-
if (this.game.device.android && !this.game.device.chrome) {
|
|
102
|
-
compat.scrollTo = new Point(0, 1);
|
|
103
|
-
} else {
|
|
104
|
-
compat.scrollTo = new Point(0, 0);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
*/
|
|
108
98
|
if (this.game.device.desktop) {
|
|
109
99
|
compat.orientationFallback = 'screen';
|
|
110
100
|
compat.clickTrampoline = 'when-not-mouse';
|
package/src/phaser/core/sound.js
CHANGED
|
@@ -196,12 +196,7 @@ export default class {
|
|
|
196
196
|
if (this._sound.stop === undefined) {
|
|
197
197
|
this._sound.noteOff(0);
|
|
198
198
|
} else {
|
|
199
|
-
|
|
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);
|
|
@@ -360,12 +355,7 @@ export default class {
|
|
|
360
355
|
this._sound.noteGrainOn(0, p, duration);
|
|
361
356
|
// this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
|
|
362
357
|
} else if (this.loop && this.game.device.chrome) {
|
|
363
|
-
|
|
364
|
-
if (this.game.device.chromeVersion === 42) {
|
|
365
|
-
this._sound.start(0);
|
|
366
|
-
} else {
|
|
367
|
-
this._sound.start(0, p);
|
|
368
|
-
}
|
|
358
|
+
this._sound.start(0, p);
|
|
369
359
|
} else {
|
|
370
360
|
this._sound.start(0, p, duration);
|
|
371
361
|
}
|
|
@@ -383,12 +373,7 @@ export default class {
|
|
|
383
373
|
if (this._sound.stop === undefined) {
|
|
384
374
|
this._sound.noteOff(0);
|
|
385
375
|
} else {
|
|
386
|
-
|
|
387
|
-
this._sound.stop(0);
|
|
388
|
-
} catch (e) {
|
|
389
|
-
// pass
|
|
390
|
-
this.game.exceptionHandler(e);
|
|
391
|
-
}
|
|
376
|
+
this._sound.stop(0);
|
|
392
377
|
}
|
|
393
378
|
if (this.externalNode) {
|
|
394
379
|
this._sound.disconnect(this.externalNode);
|
|
@@ -94,8 +94,11 @@ export default class {
|
|
|
94
94
|
if (this.noAudio) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
|
@@ -162,7 +165,7 @@ export default class {
|
|
|
162
165
|
this.onSoundDecode.dispatch(key, sound);
|
|
163
166
|
})
|
|
164
167
|
.catch((e) => {
|
|
165
|
-
this.game.exceptionHandler(e);
|
|
168
|
+
this.game.exceptionHandler(e, { key });
|
|
166
169
|
});
|
|
167
170
|
}
|
|
168
171
|
}
|
|
@@ -202,7 +205,9 @@ export default class {
|
|
|
202
205
|
this._unlockSource = null;
|
|
203
206
|
this.resumeAudioContext();
|
|
204
207
|
} else if (this.context.state === 'interrupted') {
|
|
205
|
-
this.context.resume()
|
|
208
|
+
this.context.resume().catch((e) => {
|
|
209
|
+
this.game.exceptionHandler(e, { state: this.context.state });
|
|
210
|
+
});
|
|
206
211
|
}
|
|
207
212
|
for (let i = 0; i < this._sounds.length; i += 1) {
|
|
208
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
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
+
if (window.PhaserRegistry) {
|
|
77
|
+
window.PhaserRegistry.GL_PROGRAM_INFO_LOG = gl.getProgramInfoLog(shaderProgram);
|
|
78
|
+
}
|
|
76
79
|
}
|
|
77
80
|
return shaderProgram;
|
|
78
81
|
}
|