Skip to content

Commit 0c675f7

Browse files
committed
Wrapped all events that CocoonJS doesn't support in conditional checks to avoid Cocoon Warnings.
1 parent 8bc1f99 commit 0c675f7

5 files changed

Lines changed: 33 additions & 13 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ Version 2.0.6 - "Jornhill" - -in development-
6161
* Loader.tilemap has renamed the `mapURL` parameter to `url` and `mapData` to `data` to keep it consistent with the other Loader methods.
6262
* Loader.physics has renamed the `dataURL` parameter to `url` and `jsonData` to `data` to keep it consistent with the other Loader methods.
6363

64+
### CocoonJS Specific Updates
65+
66+
* Wrapped all touch, keyboard, mouse and fulscreen events that CocoonJS doesn't support in conditional checks to avoid Warnings.
67+
6468
### New Features
6569

6670
* BitmapData.extract has a new parameter that lets you control if the destination BitmapData is resized before the pixels are copied.

src/core/ScaleManager.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,20 @@ Phaser.ScaleManager = function (game, width, height) {
240240
return _this.checkResize(event);
241241
}, false);
242242

243-
document.addEventListener('webkitfullscreenchange', function (event) {
244-
return _this.fullScreenChange(event);
245-
}, false);
243+
if (!this.game.device.cocoonJS)
244+
{
245+
document.addEventListener('webkitfullscreenchange', function (event) {
246+
return _this.fullScreenChange(event);
247+
}, false);
246248

247-
document.addEventListener('mozfullscreenchange', function (event) {
248-
return _this.fullScreenChange(event);
249-
}, false);
249+
document.addEventListener('mozfullscreenchange', function (event) {
250+
return _this.fullScreenChange(event);
251+
}, false);
250252

251-
document.addEventListener('fullscreenchange', function (event) {
252-
return _this.fullScreenChange(event);
253-
}, false);
253+
document.addEventListener('fullscreenchange', function (event) {
254+
return _this.fullScreenChange(event);
255+
}, false);
256+
}
254257

255258
};
256259

src/input/Keyboard.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ Phaser.Keyboard.prototype = {
200200
*/
201201
start: function () {
202202

203+
if (this.game.device.cocoonJS)
204+
{
205+
return;
206+
}
207+
203208
if (this._onKeyDown !== null)
204209
{
205210
// Avoid setting multiple listeners

src/input/Mouse.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ Phaser.Mouse.prototype = {
190190
this.game.canvas.addEventListener('mousedown', this._onMouseDown, true);
191191
this.game.canvas.addEventListener('mousemove', this._onMouseMove, true);
192192
this.game.canvas.addEventListener('mouseup', this._onMouseUp, true);
193-
this.game.canvas.addEventListener('mouseover', this._onMouseOver, true);
194-
this.game.canvas.addEventListener('mouseout', this._onMouseOut, true);
193+
194+
if (!this.game.device.cocoonJS)
195+
{
196+
this.game.canvas.addEventListener('mouseover', this._onMouseOver, true);
197+
this.game.canvas.addEventListener('mouseout', this._onMouseOut, true);
198+
}
195199

196200
},
197201

src/input/Touch.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,13 @@ Phaser.Touch.prototype = {
161161
this.game.canvas.addEventListener('touchstart', this._onTouchStart, false);
162162
this.game.canvas.addEventListener('touchmove', this._onTouchMove, false);
163163
this.game.canvas.addEventListener('touchend', this._onTouchEnd, false);
164-
this.game.canvas.addEventListener('touchenter', this._onTouchEnter, false);
165-
this.game.canvas.addEventListener('touchleave', this._onTouchLeave, false);
166164
this.game.canvas.addEventListener('touchcancel', this._onTouchCancel, false);
165+
166+
if (!this.game.device.cocoonJS)
167+
{
168+
this.game.canvas.addEventListener('touchenter', this._onTouchEnter, false);
169+
this.game.canvas.addEventListener('touchleave', this._onTouchLeave, false);
170+
}
167171
}
168172

169173
},

0 commit comments

Comments
 (0)