Skip to content

Commit 0786e86

Browse files
committed
Stage.scale has been moved to Game.scale. The same game scaling properties exist as before, but now accessed via Game.scale instead.
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.
1 parent 1755844 commit 0786e86

5 files changed

Lines changed: 68 additions & 101 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ Significant API changes:
7878
* Phaser.Stage now extends PIXI.Stage, rather than containing a _stage object.
7979
* If you set Sprite.exists to false it will also set Sprite.visible to false and remove its body from the physics world (if it has one).
8080
* If you set Sprite.exists to true it will also set Sprite.visible to true and add its body back into the physics world (if it has one).
81+
* Stage.scale has been moved to Game.scale. The same game scaling properties exist as before, but now accessed via Game.scale instead.
82+
* Stage.aspectRatio has been moved to StageScaleMode.sourceAspectRatio (so now game.scale.sourceAspectRatio)
83+
* Stage.scaleMode has been moved to StageScaleMode.scaleMode (so now game.scale.scaleMode)
84+
* Stage.fullScreenScaleMode has been moved to StageScaleMode.fullScreenScaleMode (so now game.scale.fullScreenScaleMode)
85+
* Stage.canvas has been removed. It was only ever an alias for Game.canvas anyway, so access it via that instead.
8186

8287

8388
New features:

src/core/Game.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,11 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
108108

109109
/**
110110
* @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout
111-
* @default
112111
*/
113112
this.raf = null;
114113

115114
/**
116115
* @property {Phaser.GameObjectFactory} add - Reference to the GameObject Factory.
117-
* @default
118116
*/
119117
this.add = null;
120118

@@ -138,92 +136,81 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
138136

139137
/**
140138
* @property {Phaser.Math} math - Reference to the math helper.
141-
* @default
142139
*/
143140
this.math = null;
144141

145142
/**
146143
* @property {Phaser.Net} net - Reference to the network class.
147-
* @default
148144
*/
149145
this.net = null;
150146

147+
/**
148+
* @property {Phaser.StageScaleMode} scale - The game scale manager.
149+
*/
150+
this.scale = null;
151+
151152
/**
152153
* @property {Phaser.SoundManager} sound - Reference to the sound manager.
153-
* @default
154154
*/
155155
this.sound = null;
156156

157157
/**
158158
* @property {Phaser.Stage} stage - Reference to the stage.
159-
* @default
160159
*/
161160
this.stage = null;
162161

163162
/**
164163
* @property {Phaser.TimeManager} time - Reference to game clock.
165-
* @default
166164
*/
167165
this.time = null;
168166

169167
/**
170168
* @property {Phaser.TweenManager} tweens - Reference to the tween manager.
171-
* @default
172169
*/
173170
this.tweens = null;
174171

175172
/**
176173
* @property {Phaser.World} world - Reference to the world.
177-
* @default
178174
*/
179175
this.world = null;
180176

181177
/**
182-
* // {Phaser.Physics.Arcade.ArcadePhysics} physics - Reference to the physics manager.
183178
* @property {Phaser.Physics.World} physics - Reference to the physics world.
184-
* @default
185179
*/
186180
this.physics = null;
187181

188182
/**
189183
* @property {Phaser.RandomDataGenerator} rnd - Instance of repeatable random data generator helper.
190-
* @default
191184
*/
192185
this.rnd = null;
193186

194187
/**
195188
* @property {Phaser.Device} device - Contains device information and capabilities.
196-
* @default
197189
*/
198190
this.device = null;
199191

200192
/**
201193
* @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera.
202-
* @default
203194
*/
204195
this.camera = null;
205196

206-
/**
207-
* @property {HTMLCanvasElement} canvas - A handy reference to renderer.view.
208-
* @default
197+
/**
198+
* @property {HTMLCanvasElement} canvas - A handy reference to renderer.view, the canvas that the game is being rendered in to.
209199
*/
210200
this.canvas = null;
211201

212202
/**
213-
* @property {Context} context - A handy reference to renderer.context (only set for CANVAS games)
214-
* @default
203+
* @property {Context} context - A handy reference to renderer.context (only set for CANVAS games, not WebGL)
215204
*/
216205
this.context = null;
217206

218207
/**
219208
* @property {Phaser.Utils.Debug} debug - A set of useful debug utilitie.
220-
* @default
221209
*/
222210
this.debug = null;
223211

224212
/**
225213
* @property {Phaser.Particles} particles - The Particle Manager.
226-
* @default
227214
*/
228215
this.particles = null;
229216

@@ -436,6 +423,7 @@ Phaser.Game.prototype = {
436423
this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]);
437424

438425
this.stage = new Phaser.Stage(this, this.width, this.height);
426+
this.scale = new Phaser.StageScaleMode(this, this.width, this.height);
439427

440428
this.setUpRenderer();
441429

src/core/Stage.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,11 @@ Phaser.Stage = function (game, width, height) {
3333
*/
3434
this.offset = new Phaser.Point();
3535

36-
/**
37-
* @property {HTMLCanvasElement} canvas - Reference to the newly created `canvas` element.
38-
*/
39-
this.canvas = null;
40-
41-
/**
42-
* @property {PIXI.Stage} _stage - The Pixi Stage which is hooked to the renderer.
43-
* @private
44-
*/
45-
// this._stage = new PIXI.Stage(0x000000, false);
46-
// this._stage.name = '_stage_root';
47-
// this._stage.interactive = false;
48-
4936
PIXI.Stage.call(this, 0x000000, false);
5037

5138
this.name = '_stage_root';
5239
this.interactive = false;
5340

54-
/**
55-
* @property {number} scaleMode - The current scaleMode.
56-
*/
57-
this.scaleMode = Phaser.StageScaleMode.NO_SCALE;
58-
59-
/*
60-
* @property {number} fullScreenScaleMode - Scale mode to be used in fullScreen
61-
*/
62-
this.fullScreenScaleMode = Phaser.StageScaleMode.NO_SCALE;
63-
64-
/**
65-
* @property {Phaser.StageScaleMode} scale - The scale of the current running game.
66-
*/
67-
// this.scale = new Phaser.StageScaleMode(this.game, width, height);
68-
69-
/**
70-
* @property {number} aspectRatio - Aspect ratio.
71-
*/
72-
this.aspectRatio = width / height;
73-
7441
/**
7542
* @property {boolean} disableVisibilityChange - By default if the browser tab loses focus the game will pause. You can stop that behaviour by setting this property to true.
7643
* @default

src/input/Pointer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Phaser.Pointer.prototype = {
207207
}
208208

209209
// Fix to stop rogue browser plugins from blocking the visibility state event
210-
if (this.game.stage.disableVisibilityChange === false && this.game.paused && this.game.stage.scale.incorrectOrientation === false)
210+
if (this.game.stage.disableVisibilityChange === false && this.game.paused && this.game.scale.incorrectOrientation === false)
211211
{
212212
this.game.paused = false;
213213
return this;

0 commit comments

Comments
 (0)