mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Fixed InputManager.updateBounds
so it factors in the document element position.
Also added `InputManager.resize` method, as the scale wouldn't ever be updated in the update loop if no interactive objects exist.
This commit is contained in:
parent
d4d2b21d6c
commit
550e53b81b
1 changed files with 27 additions and 3 deletions
|
@ -227,15 +227,39 @@ var InputManager = new Class({
|
||||||
*/
|
*/
|
||||||
updateBounds: function ()
|
updateBounds: function ()
|
||||||
{
|
{
|
||||||
var clientRect = this.canvas.getBoundingClientRect();
|
|
||||||
var bounds = this.bounds;
|
var bounds = this.bounds;
|
||||||
|
|
||||||
bounds.left = clientRect.left + window.pageXOffset;
|
var clientRect = this.canvas.getBoundingClientRect();
|
||||||
bounds.top = clientRect.top + window.pageYOffset;
|
|
||||||
|
bounds.x = clientRect.left + window.pageXOffset - document.documentElement.clientLeft;
|
||||||
|
bounds.y = clientRect.top + window.pageYOffset - document.documentElement.clientTop;
|
||||||
bounds.width = clientRect.width;
|
bounds.width = clientRect.width;
|
||||||
bounds.height = clientRect.height;
|
bounds.height = clientRect.height;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Input.InputManager#resize
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
resize: function ()
|
||||||
|
{
|
||||||
|
this.updateBounds();
|
||||||
|
|
||||||
|
// Game config size
|
||||||
|
var gw = this.game.config.width;
|
||||||
|
var gh = this.game.config.height;
|
||||||
|
|
||||||
|
// Actual canvas size
|
||||||
|
var bw = this.bounds.width;
|
||||||
|
var bh = this.bounds.height;
|
||||||
|
|
||||||
|
// Scale factor
|
||||||
|
this.scale.x = gw / bw;
|
||||||
|
this.scale.y = gh / bh;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue