@@ -65,7 +65,7 @@ var CanvasRenderer = new Class({
6565 * @type {number }
6666 * @since 3.0.0
6767 */
68- this . width = game . config . width * game . config . resolution ;
68+ this . width = game . config . width ;
6969
7070 /**
7171 * [description]
@@ -74,16 +74,22 @@ var CanvasRenderer = new Class({
7474 * @type {number }
7575 * @since 3.0.0
7676 */
77- this . height = game . config . height * game . config . resolution ;
77+ this . height = game . config . height ;
7878
7979 /**
8080 * [description]
8181 *
82- * @name Phaser.Renderer.Canvas.CanvasRenderer#resolution
83- * @type {number }
82+ * @name Phaser.Renderer.Canvas.CanvasRenderer#config
83+ * @type {object }
8484 * @since 3.0.0
8585 */
86- this . resolution = game . config . resolution ;
86+ this . config = {
87+ clearBeforeRender : game . config . clearBeforeRender ,
88+ pixelArt : game . config . pixelArt ,
89+ backgroundColor : game . config . backgroundColor ,
90+ resolution : game . config . resolution ,
91+ autoResize : game . config . autoResize
92+ } ;
8793
8894 /**
8995 * [description]
@@ -112,15 +118,6 @@ var CanvasRenderer = new Class({
112118 */
113119 this . gameContext = this . gameCanvas . getContext ( '2d' ) ;
114120
115- /**
116- * [description]
117- *
118- * @name Phaser.Renderer.Canvas.CanvasRenderer#gameConfig
119- * @type {Phaser.Boot.Config }
120- * @since 3.0.0
121- */
122- this . gameConfig = game . config ;
123-
124121 /**
125122 * [description]
126123 *
@@ -242,18 +239,18 @@ var CanvasRenderer = new Class({
242239 */
243240 resize : function ( width , height )
244241 {
245- var res = this . game . config . resolution ;
246-
247- this . width = width * res ;
248- this . height = height * res ;
242+ var resolution = this . config . resolution ;
249243
244+ this . width = width * resolution ;
245+ this . height = height * resolution ;
246+
250247 this . gameCanvas . width = this . width ;
251248 this . gameCanvas . height = this . height ;
252249
253- if ( this . autoResize )
250+ if ( this . config . autoResize )
254251 {
255- this . gameCanvas . style . width = ( this . width / res ) + 'px' ;
256- this . gameCanvas . style . height = ( this . height / res ) + 'px' ;
252+ this . gameCanvas . style . width = ( this . width / resolution ) + 'px' ;
253+ this . gameCanvas . style . height = ( this . height / resolution ) + 'px' ;
257254 }
258255
259256 // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties)
@@ -349,7 +346,7 @@ var CanvasRenderer = new Class({
349346 preRender : function ( )
350347 {
351348 var ctx = this . gameContext ;
352- var config = this . gameConfig ;
349+ var config = this . config ;
353350
354351 var width = this . width ;
355352 var height = this . height ;
@@ -384,6 +381,7 @@ var CanvasRenderer = new Class({
384381 var ctx = scene . sys . context ;
385382 var scissor = ( camera . x !== 0 || camera . y !== 0 || camera . width !== ctx . canvas . width || camera . height !== ctx . canvas . height ) ;
386383 var list = children . list ;
384+ var resolution = this . config . resolution ;
387385
388386 this . currentContext = ctx ;
389387
@@ -415,7 +413,7 @@ var CanvasRenderer = new Class({
415413 {
416414 ctx . save ( ) ;
417415 ctx . beginPath ( ) ;
418- ctx . rect ( camera . x , camera . y , camera . width , camera . height ) ;
416+ ctx . rect ( camera . x * resolution , camera . y * resolution , camera . width * resolution , camera . height * resolution ) ;
419417 ctx . clip ( ) ;
420418 }
421419
0 commit comments