Skip to content

Commit 3bc8dcd

Browse files
committed
The width and height values passed to the Game constructor are now passed through Math.floor first. This ensures you can never create a game width non-integer dimensions, which has all kinds of implications - from browser performance to breaking things like TileSprite rendering (phaserjs#2262)
1 parent 2d2101a commit 3bc8dcd

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
293293
* Sound.onEndedHandler now sets Sound.currentTime to be Sound.durationMS (thanks @stoneman1 #2237)
294294
* BitmapData would always create a private `_swapCanvas` which was a clone of its main canvas used for advanced movement operations. This no longer happens. The swap canvas is created only as needed, by those functions that use it (specifically `moveH` and `moveV`), meaning a BitmapData will now use half the amount of memory it used to, and you'll have half the amount of canvas DOM elements created (unless you make heavy use of the move functions).
295295
* Tweens with 'yoyo' set on them couldn't be re-used again because the start and end properties were left in a reversed state. When a yoyo tween ends it now restores the reversed values (thanks @SBCGames #2307)
296+
* The width and height values passed to the Game constructor are now passed through Math.floor first. This ensures you can never create a game width non-integer dimensions, which has all kinds of implications - from browser performance to breaking things like TileSprite rendering (#2262)
296297

297298
### Bug Fixes
298299

src/core/Game.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,13 @@ Phaser.Game.prototype = {
530530
return;
531531
}
532532

533+
// The game width / height must be an integer
534+
this.width = Math.floor(this.width);
535+
this.height = Math.floor(this.height);
536+
537+
this._width = Math.floor(this._width);
538+
this._height = Math.floor(this._height);
539+
533540
this.onPause = new Phaser.Signal();
534541
this.onResume = new Phaser.Signal();
535542
this.onBlur = new Phaser.Signal();

0 commit comments

Comments
 (0)