From 8ad7b25595d7170ee63f9501e600271669fda661 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 5 Apr 2016 21:52:11 +0100 Subject: [PATCH] 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) --- README.md | 1 + src/utils/Debug.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 521723e45..3c7ab9288 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * The Destroy component will now call TweenManager.removeFrom, removing any active tweens from the TweenManager upon the Game Objects destructions (thanks @PokemonAshLovesMyTurkeyAndILikeYouTwo #2408) * 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. * 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. +* 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) ### Bug Fixes diff --git a/src/utils/Debug.js b/src/utils/Debug.js index a4ef3208b..7a364b635 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -108,16 +108,38 @@ Phaser.Utils.Debug.prototype = { this.sprite = this.game.make.image(0, 0, this.bmd); this.game.stage.addChild(this.sprite); + this.game.scale.onSizeChange.add(this.resize, this); + this.canvas = PIXI.CanvasPool.create(this, this.game.width, this.game.height); this.context = this.canvas.getContext('2d'); } }, + /** + * Internal method that resizes the BitmapData and Canvas. + * Called by ScaleManager.onSizeChange only in WebGL mode. + * + * @method Phaser.Utils.Debug#resize + * @protected + * @param {Phaser.ScaleManager} scaleManager - The Phaser ScaleManager. + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (scaleManager, width, height) { + + this.bmd.resize(width, height); + + this.canvas.width = width; + this.canvas.height = height; + + }, + /** * Internal method that clears the canvas (if a Sprite) ready for a new debug session. * * @method Phaser.Utils.Debug#preUpdate + * @protected */ preUpdate: function () {