@vpmedia/phaser 1.0.32 → 1.0.34
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 +1 -1
- package/src/index.js +0 -2
- package/src/phaser/core/device.js +0 -1
- package/src/phaser/core/device_util.js +0 -49
- package/src/phaser/core/game.js +3 -15
- package/src/phaser/core/raf.js +0 -3
- package/src/phaser/core/time.js +0 -8
- package/src/phaser/display/canvas/renderer.js +0 -2
- package/src/phaser/display/webgl/render_texture.js +1 -1
- package/src/phaser/display/webgl/renderer.js +1 -3
- package/src/phaser/core/raf_fb.js +0 -75
- package/src/phaser/core/raf_to.js +0 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
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",
|
package/src/index.js
CHANGED
|
@@ -20,7 +20,6 @@ import InputPointer from './phaser/core/input_pointer';
|
|
|
20
20
|
import InputTouch from './phaser/core/input_touch';
|
|
21
21
|
import Loader from './phaser/core/loader';
|
|
22
22
|
import GameLoopRAF from './phaser/core/raf';
|
|
23
|
-
import GameLoopTO from './phaser/core/raf_to';
|
|
24
23
|
import ScaleManager from './phaser/core/scale_manager';
|
|
25
24
|
import Scene from './phaser/core/scene';
|
|
26
25
|
import SceneManager from './phaser/core/scene_manager';
|
|
@@ -89,7 +88,6 @@ export {
|
|
|
89
88
|
InputTouch,
|
|
90
89
|
Loader,
|
|
91
90
|
GameLoopRAF,
|
|
92
|
-
GameLoopTO,
|
|
93
91
|
MathUtils,
|
|
94
92
|
StringUtils,
|
|
95
93
|
ScaleManager,
|
|
@@ -264,52 +264,3 @@ export function initialize(device) {
|
|
|
264
264
|
checkFullScreenSupport(device);
|
|
265
265
|
checkInput(device);
|
|
266
266
|
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* TBD
|
|
270
|
-
*/
|
|
271
|
-
export function readyCheck() {
|
|
272
|
-
if (!document.body) {
|
|
273
|
-
window.setTimeout(readyCheck._monitor, 20);
|
|
274
|
-
} else if (!this.deviceReadyAt) {
|
|
275
|
-
this.deviceReadyAt = Date.now();
|
|
276
|
-
document.removeEventListener('deviceready', readyCheck._monitor);
|
|
277
|
-
document.removeEventListener('DOMContentLoaded', readyCheck._monitor);
|
|
278
|
-
window.removeEventListener('load', readyCheck._monitor);
|
|
279
|
-
initialize(this);
|
|
280
|
-
let item = readyCheck._queue.shift();
|
|
281
|
-
while (item) {
|
|
282
|
-
const callback = item[0];
|
|
283
|
-
const context = item[1];
|
|
284
|
-
callback.call(context, this);
|
|
285
|
-
item = readyCheck._queue.shift();
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
*
|
|
292
|
-
* @param {object} device TBD
|
|
293
|
-
* @param {Function} callback TBD
|
|
294
|
-
* @param {object} context TBD
|
|
295
|
-
* @param {boolean} nonPrimer TBD
|
|
296
|
-
*/
|
|
297
|
-
export function whenReady(device, callback, context, nonPrimer) {
|
|
298
|
-
if (device.deviceReadyAt) {
|
|
299
|
-
callback.call(context, device);
|
|
300
|
-
} else if (readyCheck._monitor || nonPrimer) {
|
|
301
|
-
readyCheck._queue = readyCheck._queue || [];
|
|
302
|
-
readyCheck._queue.push([callback, context]);
|
|
303
|
-
} else {
|
|
304
|
-
readyCheck._monitor = readyCheck.bind(device);
|
|
305
|
-
readyCheck._queue = readyCheck._queue || [];
|
|
306
|
-
readyCheck._queue.push([callback, context]);
|
|
307
|
-
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
308
|
-
// Why is there an additional timeout here?
|
|
309
|
-
window.setTimeout(readyCheck._monitor, 0);
|
|
310
|
-
} else {
|
|
311
|
-
document.addEventListener('DOMContentLoaded', readyCheck._monitor, false);
|
|
312
|
-
window.addEventListener('load', readyCheck._monitor, false);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
package/src/phaser/core/game.js
CHANGED
|
@@ -12,7 +12,6 @@ import Input from './input';
|
|
|
12
12
|
import Device from './device';
|
|
13
13
|
import GameObjectFactory from './factory';
|
|
14
14
|
import RequestAnimationFrame from './raf';
|
|
15
|
-
import TimeOutAnimationFrame from './raf_to';
|
|
16
15
|
import ScaleManager from './scale_manager';
|
|
17
16
|
import SoundManager from './sound_manager';
|
|
18
17
|
import SceneManager from './scene_manager';
|
|
@@ -69,7 +68,6 @@ export default class {
|
|
|
69
68
|
this._nextFpsNotification = 0;
|
|
70
69
|
this.parseConfig(gameConfig);
|
|
71
70
|
checkOS(this.device);
|
|
72
|
-
// whenReady(this.device, this.boot, this);
|
|
73
71
|
if (document.readyState === 'complete') {
|
|
74
72
|
initialize(this.device);
|
|
75
73
|
this.boot();
|
|
@@ -108,13 +106,9 @@ export default class {
|
|
|
108
106
|
this.sound.boot();
|
|
109
107
|
this.state.boot();
|
|
110
108
|
this.isRunning = true;
|
|
111
|
-
|
|
112
|
-
this.raf = new TimeOutAnimationFrame(this);
|
|
113
|
-
} else {
|
|
114
|
-
this.raf = new RequestAnimationFrame(this);
|
|
115
|
-
}
|
|
109
|
+
this.raf = new RequestAnimationFrame(this);
|
|
116
110
|
this.isKickStart = true;
|
|
117
|
-
if (window.focus
|
|
111
|
+
if (window.focus) {
|
|
118
112
|
window.focus();
|
|
119
113
|
}
|
|
120
114
|
this.raf.start();
|
|
@@ -190,9 +184,6 @@ export default class {
|
|
|
190
184
|
|
|
191
185
|
parseConfig(config) {
|
|
192
186
|
/* game */
|
|
193
|
-
this.parseConfigElement(config, 'isSkipWindowFocus', false);
|
|
194
|
-
this.parseConfigElement(config, 'forceSetTimeOut', false);
|
|
195
|
-
this.parseConfigElement(config, 'lockRender', false);
|
|
196
187
|
this.parseConfigElement(config, 'width', 800);
|
|
197
188
|
this.parseConfigElement(config, 'height', 600);
|
|
198
189
|
this.parseConfigElement(config, 'backgroundColor', 0x000000);
|
|
@@ -212,7 +203,7 @@ export default class {
|
|
|
212
203
|
this.parseConfigElement(config, 'preserveDrawingBuffer', false);
|
|
213
204
|
// Clear the Canvas each frame before rendering the display list.
|
|
214
205
|
// You can set this to `false` to gain some performance if your game always contains a background that completely fills the display.
|
|
215
|
-
this.parseConfigElement(config, 'clearBeforeRender',
|
|
206
|
+
this.parseConfigElement(config, 'clearBeforeRender', false);
|
|
216
207
|
// The Renderer this game will use. Either Const.RENDER_AUTO, Const.RENDER_CANVAS, Const.RENDER_WEBGL
|
|
217
208
|
this.parseConfigElement(config, 'renderType', RENDER_AUTO);
|
|
218
209
|
// Force audio disabled
|
|
@@ -341,9 +332,6 @@ export default class {
|
|
|
341
332
|
}
|
|
342
333
|
|
|
343
334
|
updateRender(elapsedTime) {
|
|
344
|
-
if (this.config.lockRender) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
335
|
this.state.preRender(elapsedTime);
|
|
348
336
|
this.renderer.render(this.stage);
|
|
349
337
|
this.state.render(elapsedTime);
|
package/src/phaser/core/raf.js
CHANGED
|
@@ -20,7 +20,6 @@ export default class {
|
|
|
20
20
|
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
|
21
21
|
}
|
|
22
22
|
this.updateBinded = this.update.bind(this);
|
|
23
|
-
// this.updateBinded = time => this.update(time);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
start() {
|
|
@@ -37,8 +36,6 @@ export default class {
|
|
|
37
36
|
if (!this.isRunning) {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
|
-
// floor the rafTime to make it equivalent to the Date.now() provided by updateSetTimeout (just below)
|
|
41
|
-
// this.game.update(Math.floor(rafTime));
|
|
42
39
|
this.game.update(rafTime);
|
|
43
40
|
this.timeoutId = window.requestAnimationFrame(this.updateBinded);
|
|
44
41
|
}
|
package/src/phaser/core/time.js
CHANGED
|
@@ -87,14 +87,6 @@ export default class {
|
|
|
87
87
|
this.now = time;
|
|
88
88
|
// elapsed time between previous call and now - this could be a high resolution value
|
|
89
89
|
this.elapsed = this.now - this.prevTime;
|
|
90
|
-
if (this.game.raf._isSetTimeOut) {
|
|
91
|
-
// console.log('Time isSet', this._desiredFps, 'te', this.timeExpected, 'time', time);
|
|
92
|
-
// time to call this function again in ms in case we're using timers instead of RequestAnimationFrame to update the game
|
|
93
|
-
this.timeToCall = Math.floor(Math.max(0, (1000.0 / this._desiredFps) - (this.timeExpected - time)));
|
|
94
|
-
// time when the next call is expected if using timers
|
|
95
|
-
this.timeExpected = time + this.timeToCall;
|
|
96
|
-
// console.log('Time expect', this.timeExpected);
|
|
97
|
-
}
|
|
98
90
|
if (this.advancedTiming) {
|
|
99
91
|
this.updateAdvancedTiming();
|
|
100
92
|
}
|
|
@@ -36,7 +36,6 @@ export default class {
|
|
|
36
36
|
};
|
|
37
37
|
this.mapBlendModes();
|
|
38
38
|
this.resize(this.width, this.height);
|
|
39
|
-
window.PhaserRegistry.DEFAULT_RENDERER = this;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
render(root) {
|
|
@@ -67,7 +66,6 @@ export default class {
|
|
|
67
66
|
this.view = null;
|
|
68
67
|
this.context = null;
|
|
69
68
|
this.renderSession = null;
|
|
70
|
-
window.PhaserRegistry.DEFAULT_RENDERER = null;
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
resize(width, height) {
|
|
@@ -31,7 +31,7 @@ export default class extends Texture {
|
|
|
31
31
|
this.resolution = res;
|
|
32
32
|
this.frame = new Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution);
|
|
33
33
|
this.crop = new Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution);
|
|
34
|
-
this.renderer = renderer
|
|
34
|
+
this.renderer = renderer;
|
|
35
35
|
if (this.renderer.type === RENDER_WEBGL) {
|
|
36
36
|
const gl = this.renderer.gl;
|
|
37
37
|
this.baseTexture._dirty[gl.id] = false;
|
|
@@ -54,7 +54,6 @@ export default class {
|
|
|
54
54
|
this.renderSession.resolution = this.resolution;
|
|
55
55
|
this.initContext();
|
|
56
56
|
this.mapBlendModes();
|
|
57
|
-
window.PhaserRegistry.DEFAULT_RENDERER = this;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
destroy() {
|
|
@@ -79,7 +78,6 @@ export default class {
|
|
|
79
78
|
this.renderSession = null;
|
|
80
79
|
remove(this);
|
|
81
80
|
window.PhaserRegistry.INSTANCES[this.glContextId] = null;
|
|
82
|
-
window.PhaserRegistry.DEFAULT_RENDERER = null;
|
|
83
81
|
window.PhaserRegistry.GL_CONTEXT_ID -= 1;
|
|
84
82
|
}
|
|
85
83
|
|
|
@@ -129,7 +127,7 @@ export default class {
|
|
|
129
127
|
}
|
|
130
128
|
const gl = this.gl;
|
|
131
129
|
// -- Does this need to be set every frame? -- //
|
|
132
|
-
gl.viewport(0, 0, this.width, this.height);
|
|
130
|
+
// gl.viewport(0, 0, this.width, this.height);
|
|
133
131
|
// make sure we are bound to the main frame buffer
|
|
134
132
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
135
133
|
if (this.clearBeforeRender) {
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
|
-
*/
|
|
6
|
-
export default class {
|
|
7
|
-
|
|
8
|
-
constructor(game, forceSetTimeOut = false) {
|
|
9
|
-
this.game = game;
|
|
10
|
-
this.forceSetTimeOut = forceSetTimeOut;
|
|
11
|
-
this.isRunning = false;
|
|
12
|
-
this._isSetTimeOut = false;
|
|
13
|
-
this._onLoop = null;
|
|
14
|
-
this._timeOutID = null;
|
|
15
|
-
const vendors = [
|
|
16
|
-
'ms',
|
|
17
|
-
'moz',
|
|
18
|
-
'webkit',
|
|
19
|
-
'o',
|
|
20
|
-
];
|
|
21
|
-
for (let x = 0; x < vendors.length && !window.requestAnimationFrame; x += 1) {
|
|
22
|
-
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
|
23
|
-
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
start() {
|
|
28
|
-
const scope = this;
|
|
29
|
-
this.isRunning = true;
|
|
30
|
-
if (!window.requestAnimationFrame || this.forceSetTimeOut) {
|
|
31
|
-
this._isSetTimeOut = true;
|
|
32
|
-
this._onLoop = () => scope.updateSetTimeout();
|
|
33
|
-
this._timeOutID = window.setTimeout(this._onLoop, 0);
|
|
34
|
-
} else {
|
|
35
|
-
this._isSetTimeOut = false;
|
|
36
|
-
this._onLoop = time => scope.updateRAF(time);
|
|
37
|
-
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
stop() {
|
|
42
|
-
this.isRunning = false;
|
|
43
|
-
if (this._isSetTimeOut) {
|
|
44
|
-
window.clearTimeout(this._timeOutID);
|
|
45
|
-
} else {
|
|
46
|
-
window.cancelAnimationFrame(this._timeOutID);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
updateRAF(rafTime) {
|
|
51
|
-
if (!this.isRunning) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// floor the rafTime to make it equivalent to the Date.now() provided by updateSetTimeout (just below)
|
|
55
|
-
this.game.update(Math.floor(rafTime));
|
|
56
|
-
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
updateSetTimeout() {
|
|
60
|
-
if (!this.isRunning) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.game.update(Date.now());
|
|
64
|
-
this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isSetTimeOut() {
|
|
68
|
-
return this._isSetTimeOut;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
isRAF() {
|
|
72
|
-
return this._isSetTimeOut === false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
|
-
*/
|
|
6
|
-
export default class {
|
|
7
|
-
|
|
8
|
-
constructor(game) {
|
|
9
|
-
this.game = game;
|
|
10
|
-
this.isRunning = false;
|
|
11
|
-
this.isSetTimeOut = true;
|
|
12
|
-
this.timeoutId = null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
start() {
|
|
16
|
-
this.isRunning = true;
|
|
17
|
-
this.timeoutId = window.setTimeout(this.update, 0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
stop() {
|
|
21
|
-
window.clearTimeout(this.timeoutId);
|
|
22
|
-
this.isRunning = false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
update() {
|
|
26
|
-
if (!this.isRunning) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.game.update(Date.now());
|
|
30
|
-
this.timeoutId = window.setTimeout(this.update, this.game.time.timeToCall);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|