Skip to content

Commit 74eeddf

Browse files
committed
You can now set a resolution property in your Game Configuration object. This will be read when the Pixi renderer instance is created and used to set the resolution within that (phaserjs#1621)
1 parent 41396d5 commit 74eeddf

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ We've also removed functions and properties from Pixi classes that Phaser doesn'
159159
* Tween.interpolation has a new parameter `context` which allows you to define the context in which the interpolation function will run.
160160
* ArraySet.getByKey gets an item from the set based on the property strictly equaling the value given.
161161
* A State swap now sets the Loader.reset `hard` parameter to `true` by default. This will null any Loader.preloadSprite that may have been set.
162+
* You can now set a `resolution` property in your Game Configuration object. This will be read when the Pixi renderer instance is created and used to set the resolution within that (#1621)
162163

163164
### Bug Fixes
164165

src/core/Game.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
6868
*/
6969
this.height = 600;
7070

71+
/**
72+
* The resolution of your game. This value is read only, but can be changed at start time it via a game configuration object.
73+
*
74+
* @property {integer} resolution
75+
* @readonly
76+
* @default
77+
*/
78+
this.resolution = 1;
79+
7180
/**
7281
* @property {integer} _width - Private internal var.
7382
* @private
@@ -460,6 +469,11 @@ Phaser.Game.prototype = {
460469
this.antialias = config['antialias'];
461470
}
462471

472+
if (config['resolution'])
473+
{
474+
this.resolution = config['resolution'];
475+
}
476+
463477
if (config['preserveDrawingBuffer'])
464478
{
465479
this.preserveDrawingBuffer = config['preserveDrawingBuffer'];
@@ -683,7 +697,10 @@ Phaser.Game.prototype = {
683697
this.renderType = Phaser.CANVAS;
684698
}
685699

686-
this.renderer = new PIXI.CanvasRenderer(this.width, this.height, { "view": this.canvas, "transparent": this.transparent, "resolution": 1, "clearBeforeRender": true });
700+
this.renderer = new PIXI.CanvasRenderer(this.width, this.height, { "view": this.canvas,
701+
"transparent": this.transparent,
702+
"resolution": this.resolution,
703+
"clearBeforeRender": true });
687704
this.context = this.renderer.context;
688705
}
689706
else
@@ -696,7 +713,11 @@ Phaser.Game.prototype = {
696713
// They requested WebGL and their browser supports it
697714
this.renderType = Phaser.WEBGL;
698715

699-
this.renderer = new PIXI.WebGLRenderer(this.width, this.height, { "view": this.canvas, "transparent": this.transparent, "resolution": 1, "antialias": this.antialias, "preserveDrawingBuffer": this.preserveDrawingBuffer });
716+
this.renderer = new PIXI.WebGLRenderer(this.width, this.height, { "view": this.canvas,
717+
"transparent": this.transparent,
718+
"resolution": this.resolution,
719+
"antialias": this.antialias,
720+
"preserveDrawingBuffer": this.preserveDrawingBuffer });
700721
this.context = null;
701722
}
702723

0 commit comments

Comments
 (0)