Skip to content

Commit 8ad7b25

Browse files
committed
The Debug canvas now listens for the ScaleManager.onSizeChange signal and resizes itself accordingly when running under WebGL. This means if your game size changes the Debug canvas won't be clipped off (thanks @francisberesford phaserjs#1919)
1 parent 7b80313 commit 8ad7b25

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
340340
* The Destroy component will now call TweenManager.removeFrom, removing any active tweens from the TweenManager upon the Game Objects destructions (thanks @PokemonAshLovesMyTurkeyAndILikeYouTwo #2408)
341341
* Tween.update will now return `false` (flagging the Tween for destruction) should the Tween.target property every become falsey. This can happen if the object the Tween was tracking is destroyed, nulled or generally removed.
342342
* TweenData.repeatTotal is a new property that keeps track of the total number of times the Tween should repeat. If TweenData.start is called, as a result of the Tween repeatCount being > 0 then the child tween resets its total before re-starting.
343+
* The Debug canvas now listens for the ScaleManager.onSizeChange signal and resizes itself accordingly when running under WebGL. This means if your game size changes the Debug canvas won't be clipped off (thanks @francisberesford #1919)
343344

344345
### Bug Fixes
345346

src/utils/Debug.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,38 @@ Phaser.Utils.Debug.prototype = {
108108
this.sprite = this.game.make.image(0, 0, this.bmd);
109109
this.game.stage.addChild(this.sprite);
110110

111+
this.game.scale.onSizeChange.add(this.resize, this);
112+
111113
this.canvas = PIXI.CanvasPool.create(this, this.game.width, this.game.height);
112114
this.context = this.canvas.getContext('2d');
113115
}
114116

115117
},
116118

119+
/**
120+
* Internal method that resizes the BitmapData and Canvas.
121+
* Called by ScaleManager.onSizeChange only in WebGL mode.
122+
*
123+
* @method Phaser.Utils.Debug#resize
124+
* @protected
125+
* @param {Phaser.ScaleManager} scaleManager - The Phaser ScaleManager.
126+
* @param {number} width - The new width of the game.
127+
* @param {number} height - The new height of the game.
128+
*/
129+
resize: function (scaleManager, width, height) {
130+
131+
this.bmd.resize(width, height);
132+
133+
this.canvas.width = width;
134+
this.canvas.height = height;
135+
136+
},
137+
117138
/**
118139
* Internal method that clears the canvas (if a Sprite) ready for a new debug session.
119140
*
120141
* @method Phaser.Utils.Debug#preUpdate
142+
* @protected
121143
*/
122144
preUpdate: function () {
123145

0 commit comments

Comments
 (0)