From e9fb8f6389fe75ab44de2e702073ba16d6375b66 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 13 Feb 2014 12:55:58 +0000 Subject: [PATCH] Updates across the board moving Stage.canvas to Game.canvas --- README.md | 2 +- src/core/Game.js | 4 ++-- src/core/Stage.js | 4 ++-- src/core/StateManager.js | 1 + src/input/MSPointer.js | 12 ++++++------ src/input/Mouse.js | 4 ++-- src/input/Touch.js | 12 ++++++------ src/system/StageScaleMode.js | 8 ++++---- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 65fe4284..378c8cbd 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Significant API changes: * Stage.aspectRatio has been moved to StageScaleMode.sourceAspectRatio (so now game.scale.sourceAspectRatio) * Stage.scaleMode has been moved to StageScaleMode.scaleMode (so now game.scale.scaleMode) * Stage.fullScreenScaleMode has been moved to StageScaleMode.fullScreenScaleMode (so now game.scale.fullScreenScaleMode) -* Stage.canvas has been removed. It was only ever an alias for Game.canvas anyway, so access it via that instead. +* Stage.canvas has been moved to Game.canvas (which used to be a reference to Stage.canvas, but is now the actual object). New features: diff --git a/src/core/Game.js b/src/core/Game.js index 4ccdfe8e..fc65062f 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -532,7 +532,7 @@ Phaser.Game.prototype = { this.renderType = Phaser.CANVAS; } - this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.stage.canvas, this.transparent); + this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.canvas, this.transparent); Phaser.Canvas.setSmoothingEnabled(this.renderer.context, this.antialias); this.canvas = this.renderer.view; this.context = this.renderer.context; @@ -546,7 +546,7 @@ Phaser.Game.prototype = { { // They requested WebGL, and their browser supports it this.renderType = Phaser.WEBGL; - this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.stage.canvas, this.transparent, this.antialias); + this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.canvas, this.transparent, this.antialias); this.canvas = this.renderer.view; this.context = null; } diff --git a/src/core/Stage.js b/src/core/Stage.js index cce76b0c..b357a2df 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -62,8 +62,8 @@ Phaser.Stage = function (game, width, height) { } else { - this.canvas = Phaser.Canvas.create(width, height); - this.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%'; + this.game.canvas = Phaser.Canvas.create(width, height); + this.game.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%'; } }; diff --git a/src/core/StateManager.js b/src/core/StateManager.js index 00f70d1a..757a3879 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -334,6 +334,7 @@ Phaser.StateManager.prototype = { this.states[key].load = this.game.load; this.states[key].math = this.game.math; this.states[key].sound = this.game.sound; + this.states[key].scale = this.game.scale; this.states[key].stage = this.game.stage; this.states[key].time = this.game.time; this.states[key].tweens = this.game.tweens; diff --git a/src/input/MSPointer.js b/src/input/MSPointer.js index 5d6f4300..b48cced1 100644 --- a/src/input/MSPointer.js +++ b/src/input/MSPointer.js @@ -155,13 +155,13 @@ Phaser.MSPointer.prototype = { */ stop: function () { - this.game.stage.canvas.removeEventListener('MSPointerDown', this._onMSPointerDown); - this.game.stage.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove); - this.game.stage.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp); + this.game.canvas.removeEventListener('MSPointerDown', this._onMSPointerDown); + this.game.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove); + this.game.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp); - this.game.stage.canvas.removeEventListener('pointerDown', this._onMSPointerDown); - this.game.stage.canvas.removeEventListener('pointerMove', this._onMSPointerMove); - this.game.stage.canvas.removeEventListener('pointerUp', this._onMSPointerUp); + this.game.canvas.removeEventListener('pointerDown', this._onMSPointerDown); + this.game.canvas.removeEventListener('pointerMove', this._onMSPointerMove); + this.game.canvas.removeEventListener('pointerUp', this._onMSPointerUp); } diff --git a/src/input/Mouse.js b/src/input/Mouse.js index c8ced562..a5fd29fe 100644 --- a/src/input/Mouse.js +++ b/src/input/Mouse.js @@ -255,7 +255,7 @@ Phaser.Mouse.prototype = { if (this.game.device.pointerLock) { - var element = this.game.stage.canvas; + var element = this.game.canvas; element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; @@ -281,7 +281,7 @@ Phaser.Mouse.prototype = { */ pointerLockChange: function (event) { - var element = this.game.stage.canvas; + var element = this.game.canvas; if (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) { diff --git a/src/input/Touch.js b/src/input/Touch.js index 67715f80..b9701118 100644 --- a/src/input/Touch.js +++ b/src/input/Touch.js @@ -356,12 +356,12 @@ Phaser.Touch.prototype = { if (this.game.device.touch) { - this.game.stage.canvas.removeEventListener('touchstart', this._onTouchStart); - this.game.stage.canvas.removeEventListener('touchmove', this._onTouchMove); - this.game.stage.canvas.removeEventListener('touchend', this._onTouchEnd); - this.game.stage.canvas.removeEventListener('touchenter', this._onTouchEnter); - this.game.stage.canvas.removeEventListener('touchleave', this._onTouchLeave); - this.game.stage.canvas.removeEventListener('touchcancel', this._onTouchCancel); + this.game.canvas.removeEventListener('touchstart', this._onTouchStart); + this.game.canvas.removeEventListener('touchmove', this._onTouchMove); + this.game.canvas.removeEventListener('touchend', this._onTouchEnd); + this.game.canvas.removeEventListener('touchenter', this._onTouchEnter); + this.game.canvas.removeEventListener('touchleave', this._onTouchLeave); + this.game.canvas.removeEventListener('touchcancel', this._onTouchCancel); } } diff --git a/src/system/StageScaleMode.js b/src/system/StageScaleMode.js index ab1f7ebf..702b1f08 100644 --- a/src/system/StageScaleMode.js +++ b/src/system/StageScaleMode.js @@ -320,8 +320,8 @@ Phaser.StageScaleMode.prototype = { { if (this.fullScreenScaleMode === Phaser.StageScaleMode.EXACT_FIT) { - this.game.stage.canvas.style['width'] = '100%'; - this.game.stage.canvas.style['height'] = '100%'; + this.game.canvas.style['width'] = '100%'; + this.game.canvas.style['height'] = '100%'; this.setMaximum(); @@ -339,8 +339,8 @@ Phaser.StageScaleMode.prototype = { } else { - this.game.stage.canvas.style['width'] = this.game.width + 'px'; - this.game.stage.canvas.style['height'] = this.game.height + 'px'; + this.game.canvas.style['width'] = this.game.width + 'px'; + this.game.canvas.style['height'] = this.game.height + 'px'; this.width = this._width; this.height = this._height;