@vpmedia/phaser 1.0.4 → 1.0.5

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.4",
3
+ "version": "1.0.5",
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",
@@ -11,9 +11,6 @@ export default class {
11
11
  this.desktop = false;
12
12
  this.iOS = false;
13
13
  this.iOSVersion = 0;
14
- this.cocoonJS = false;
15
- this.cocoonJSApp = false;
16
- this.cordova = false;
17
14
  this.node = false;
18
15
  this.android = false;
19
16
  this.chromeOS = false;
@@ -30,10 +27,6 @@ export default class {
30
27
  this.chromeVersion = 0;
31
28
  this.firefox = false;
32
29
  this.firefoxVersion = 0;
33
- this.ie = false;
34
- this.ieVersion = 0;
35
- this.trident = false;
36
- this.tridentVersion = 0;
37
30
  this.edge = false;
38
31
  this.mobileSafari = false;
39
32
  this.safari = false;
@@ -109,18 +109,9 @@ export function checkInput(device) {
109
109
  if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) {
110
110
  device.mspointer = true;
111
111
  }
112
- if (!device.cocoonJS) {
113
- // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel
114
- if ('onwheel' in window || (device.ie && 'WheelEvent' in window)) {
115
- // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+
116
- device.wheelEvent = 'wheel';
117
- } else if ('onmousewheel' in window) {
118
- // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7.
119
- device.wheelEvent = 'mousewheel';
120
- } else if (device.firefox && 'MouseScrollEvent' in window) {
121
- // FF prior to 17. This should probably be scrubbed.
122
- device.wheelEvent = 'DOMMouseScroll';
123
- }
112
+ // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel
113
+ if ('onwheel' in window || 'WheelEvent' in window) {
114
+ device.wheelEvent = 'wheel';
124
115
  }
125
116
  }
126
117
 
@@ -186,19 +177,11 @@ export function checkBrowser(device) {
186
177
  device.firefoxVersion = parseInt(RegExp.$1, 10);
187
178
  } else if (/AppleWebKit/.test(ua) && device.iOS) {
188
179
  device.mobileSafari = true;
189
- } else if (/MSIE (\d+\.\d+);/.test(ua)) {
190
- device.ie = true;
191
- device.ieVersion = parseInt(RegExp.$1, 10);
192
180
  } else if (/Safari\/(\d+)/.test(ua) && !device.windowsPhone) {
193
181
  device.safari = true;
194
182
  if (/Version\/(\d+)\./.test(ua)) {
195
183
  device.safariVersion = parseInt(RegExp.$1, 10);
196
184
  }
197
- } else if (/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(ua)) {
198
- device.ie = true;
199
- device.trident = true;
200
- device.tridentVersion = parseInt(RegExp.$1, 10);
201
- device.ieVersion = parseInt(RegExp.$3, 10);
202
185
  }
203
186
  // Silk gets its own if clause because its ua also contains 'Safari'
204
187
  if (/Silk/.test(ua)) {
@@ -208,22 +191,9 @@ export function checkBrowser(device) {
208
191
  if (navigator.standalone) {
209
192
  device.webApp = true;
210
193
  }
211
- if (typeof window.cordova !== 'undefined') {
212
- device.cordova = true;
213
- }
214
194
  if (typeof process !== 'undefined' && typeof require !== 'undefined') {
215
195
  device.node = true;
216
196
  }
217
- if (navigator.isCocoonJS) {
218
- device.cocoonJS = true;
219
- }
220
- if (device.cocoonJS) {
221
- try {
222
- device.cocoonJSApp = (typeof CocoonJS !== 'undefined');
223
- } catch (e) {
224
- device.cocoonJSApp = false;
225
- }
226
- }
227
197
  }
228
198
 
229
199
  /**
@@ -371,15 +341,9 @@ export function whenReady(device, callback, context, nonPrimer) {
371
341
  readyCheck._monitor = readyCheck.bind(device);
372
342
  readyCheck._queue = readyCheck._queue || [];
373
343
  readyCheck._queue.push([callback, context]);
374
- const cordova = typeof window.cordova !== 'undefined';
375
- const cocoonJS = navigator.isCocoonJS;
376
344
  if (document.readyState === 'complete' || document.readyState === 'interactive') {
377
345
  // Why is there an additional timeout here?
378
346
  window.setTimeout(readyCheck._monitor, 0);
379
- } else if (cordova && !cocoonJS) {
380
- // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready
381
- // Cordova, but NOT Cocoon?
382
- document.addEventListener('deviceready', readyCheck._monitor, false);
383
347
  } else {
384
348
  document.addEventListener('DOMContentLoaded', readyCheck._monitor, false);
385
349
  window.addEventListener('load', readyCheck._monitor, false);
@@ -168,9 +168,6 @@ export default class {
168
168
  this.renderer = new CanvasRenderer(this);
169
169
  this.context = this.renderer.context;
170
170
  }
171
- if (this.device && this.device.cocoonJS && this.renderer) {
172
- this.canvas.screencanvas = this.renderer.type === RENDER_CANVAS;
173
- }
174
171
  if (this.config.renderType !== RENDER_HEADLESS) {
175
172
  this.stage.smoothed = this.config.antialias;
176
173
  addToDOM(this.canvas, this.parent, false);
@@ -106,20 +106,13 @@ export default class {
106
106
  canvas.addEventListener('mousedown', this._onMouseDown, true);
107
107
  canvas.addEventListener('mousemove', this._onMouseMove, true);
108
108
  canvas.addEventListener('mouseup', this._onMouseUp, true);
109
- if (!this.game.device.cocoonJS) {
110
- window.addEventListener('mouseup', this._onMouseUpGlobal, true);
111
- window.addEventListener('mouseout', this._onMouseOutGlobal, true);
112
- canvas.addEventListener('mouseover', this._onMouseOver, true);
113
- canvas.addEventListener('mouseout', this._onMouseOut, true);
114
- }
109
+ window.addEventListener('mouseup', this._onMouseUpGlobal, true);
110
+ window.addEventListener('mouseout', this._onMouseOutGlobal, true);
111
+ canvas.addEventListener('mouseover', this._onMouseOver, true);
112
+ canvas.addEventListener('mouseout', this._onMouseOut, true);
115
113
  const wheelEvent = this.game.device.wheelEvent;
116
114
  if (wheelEvent) {
117
115
  canvas.addEventListener(wheelEvent, this._onMouseWheel, true);
118
- if (wheelEvent === 'mousewheel') {
119
- this._wheelEvent = new WheelEventProxy(-1 / 40, 1);
120
- } else if (wheelEvent === 'DOMMouseScroll') {
121
- this._wheelEvent = new WheelEventProxy(1, 1);
122
- }
123
116
  }
124
117
  }
125
118
 
@@ -46,15 +46,13 @@ export default class {
46
46
  canvas.addEventListener('pointerup', this._onMSPointerUp, false);
47
47
  canvas.style['-ms-content-zooming'] = 'none';
48
48
  canvas.style['-ms-touch-action'] = 'none';
49
- if (!this.game.device.cocoonJS) {
50
- window.addEventListener('MSPointerUp', this._onMSPointerUpGlobal, true);
51
- canvas.addEventListener('MSPointerOver', this._onMSPointerOver, true);
52
- canvas.addEventListener('MSPointerOut', this._onMSPointerOut, true);
53
- // IE11+ uses non-prefix events
54
- window.addEventListener('pointerup', this._onMSPointerUpGlobal, true);
55
- canvas.addEventListener('pointerover', this._onMSPointerOver, true);
56
- canvas.addEventListener('pointerout', this._onMSPointerOut, true);
57
- }
49
+ window.addEventListener('MSPointerUp', this._onMSPointerUpGlobal, true);
50
+ canvas.addEventListener('MSPointerOver', this._onMSPointerOver, true);
51
+ canvas.addEventListener('MSPointerOut', this._onMSPointerOut, true);
52
+ // IE11+ uses non-prefix events
53
+ window.addEventListener('pointerup', this._onMSPointerUpGlobal, true);
54
+ canvas.addEventListener('pointerover', this._onMSPointerOver, true);
55
+ canvas.addEventListener('pointerout', this._onMSPointerOut, true);
58
56
  }
59
57
 
60
58
  stop() {
@@ -42,10 +42,8 @@ export default class {
42
42
  this.game.canvas.addEventListener('touchmove', this._onTouchMove, false);
43
43
  this.game.canvas.addEventListener('touchend', this._onTouchEnd, false);
44
44
  this.game.canvas.addEventListener('touchcancel', this._onTouchCancel, false);
45
- if (!this.game.device.cocoonJS) {
46
- this.game.canvas.addEventListener('touchenter', this._onTouchEnter, false);
47
- this.game.canvas.addEventListener('touchleave', this._onTouchLeave, false);
48
- }
45
+ this.game.canvas.addEventListener('touchenter', this._onTouchEnter, false);
46
+ this.game.canvas.addEventListener('touchleave', this._onTouchLeave, false);
49
47
  }
50
48
 
51
49
  stop() {
@@ -94,7 +94,7 @@ export default class {
94
94
  boot() {
95
95
  // Configure device-dependent compatibility
96
96
  const compat = this.compatibility;
97
- compat.supportsFullScreen = this.game.device.fullscreen && !this.game.device.cocoonJS;
97
+ compat.supportsFullScreen = this.game.device.fullscreen;
98
98
  // We can't do anything about the status bars in iPads, web apps or desktops
99
99
  /*
100
100
  if (!this.game.device.iPad && !this.game.device.webApp && !this.game.device.desktop) {
@@ -311,7 +311,7 @@ export default class {
311
311
  } else if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked) {
312
312
  this.game.cache.reloadSound(this.key);
313
313
  this.pendingPlayback = true;
314
- } else if (this._sound && (this.game.device.cocoonJS || this._sound.readyState === 4)) {
314
+ } else if (this._sound && this._sound.readyState === 4) {
315
315
  this._sound.play();
316
316
  // This doesn't become available until you call play(), wonderful ...
317
317
  this.totalDuration = this._sound.duration;
@@ -75,7 +75,7 @@ export default class {
75
75
  this.game.input.onUp.addOnce(this.resumeWebAudio, this);
76
76
  }
77
77
  }
78
- if (!this.noAudio && !this.game.device.cocoonJS && (this.game.device.iOS || this.game.device.android)) {
78
+ if (!this.noAudio && (this.game.device.iOS || this.game.device.android)) {
79
79
  this.game.input.addTouchLockCallback(this.unlock, this, true);
80
80
  this.touchLocked = true;
81
81
  }
@@ -49,10 +49,6 @@ export default class {
49
49
  this.renderSession.shakeX = 0;
50
50
  this.renderSession.shakeY = 0;
51
51
  this.context.globalCompositeOperation = 'source-over';
52
- if (navigator.isCocoonJS && this.view.screencanvas) {
53
- this.context.fillStyle = 'black';
54
- this.context.clear();
55
- }
56
52
  if (this.clearBeforeRender) {
57
53
  if (this.transparent) {
58
54
  this.context.clearRect(0, 0, this.width, this.height);
@@ -196,9 +196,6 @@ export default class extends Image {
196
196
  }
197
197
  this.canvas.height = height * this._res;
198
198
  this.context.scale(this._res, this._res);
199
- if (navigator.isCocoonJS) {
200
- this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
201
- }
202
199
  if (this.style.backgroundColor) {
203
200
  this.context.fillStyle = this.style.backgroundColor;
204
201
  this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);