@vpmedia/phaser 1.0.33 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/phaser",
3
- "version": "1.0.33",
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,
@@ -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';
@@ -107,13 +106,9 @@ export default class {
107
106
  this.sound.boot();
108
107
  this.state.boot();
109
108
  this.isRunning = true;
110
- if (this.config.forceSetTimeOut) {
111
- this.raf = new TimeOutAnimationFrame(this);
112
- } else {
113
- this.raf = new RequestAnimationFrame(this);
114
- }
109
+ this.raf = new RequestAnimationFrame(this);
115
110
  this.isKickStart = true;
116
- if (window.focus && !this.config.isSkipWindowFocus) {
111
+ if (window.focus) {
117
112
  window.focus();
118
113
  }
119
114
  this.raf.start();
@@ -189,9 +184,6 @@ export default class {
189
184
 
190
185
  parseConfig(config) {
191
186
  /* game */
192
- this.parseConfigElement(config, 'isSkipWindowFocus', false);
193
- this.parseConfigElement(config, 'forceSetTimeOut', false);
194
- this.parseConfigElement(config, 'lockRender', false);
195
187
  this.parseConfigElement(config, 'width', 800);
196
188
  this.parseConfigElement(config, 'height', 600);
197
189
  this.parseConfigElement(config, 'backgroundColor', 0x000000);
@@ -211,7 +203,7 @@ export default class {
211
203
  this.parseConfigElement(config, 'preserveDrawingBuffer', false);
212
204
  // Clear the Canvas each frame before rendering the display list.
213
205
  // You can set this to `false` to gain some performance if your game always contains a background that completely fills the display.
214
- this.parseConfigElement(config, 'clearBeforeRender', true);
206
+ this.parseConfigElement(config, 'clearBeforeRender', false);
215
207
  // The Renderer this game will use. Either Const.RENDER_AUTO, Const.RENDER_CANVAS, Const.RENDER_WEBGL
216
208
  this.parseConfigElement(config, 'renderType', RENDER_AUTO);
217
209
  // Force audio disabled
@@ -340,9 +332,6 @@ export default class {
340
332
  }
341
333
 
342
334
  updateRender(elapsedTime) {
343
- if (this.config.lockRender) {
344
- return;
345
- }
346
335
  this.state.preRender(elapsedTime);
347
336
  this.renderer.render(this.stage);
348
337
  this.state.render(elapsedTime);
@@ -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
  }
@@ -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 || window.PhaserRegistry.DEFAULT_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
 
@@ -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
- }