Skip to content

Commit 9787474

Browse files
committed
Camera.checkBounds now takes the scale of the Camera into account (thanks @ForGorNorPor phaserjs#2263)
1 parent a7c3604 commit 9787474

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
305305
* SoundManager.setTouchLock is no longer set if `SoundManager.noAudio` is true, or if the PhaserGlobal setting `disableAudio` is true (thanks @bcjordan #2206)
306306
* Loader.audiosprite is renamed to Loader.audioSprite (the old one still works for legacy reasons) (thanks @epaezrubio #2145)
307307
* EarCut now replaces PolyK, which fixes advanced Graphics mask triangulation issues such as #1941
308+
* Camera.checkBounds now takes the scale of the Camera into account (thanks @ForGorNorPor #2263)
308309

309310
### Bug Fixes
310311

src/core/Camera.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,28 +332,28 @@ Phaser.Camera.prototype = {
332332
this.atLimit.y = false;
333333

334334
// Make sure we didn't go outside the cameras bounds
335-
if (this.view.x <= this.bounds.x)
335+
if (this.view.x <= this.bounds.x * this.scale.x)
336336
{
337337
this.atLimit.x = true;
338-
this.view.x = this.bounds.x;
338+
this.view.x = this.bounds.x * this.scale.x;
339339
}
340340

341-
if (this.view.right >= this.bounds.right)
341+
if (this.view.right >= this.bounds.right * this.scale.x)
342342
{
343343
this.atLimit.x = true;
344-
this.view.x = this.bounds.right - this.width;
344+
this.view.x = (this.bounds.right * this.scale.x) - this.width;
345345
}
346346

347-
if (this.view.y <= this.bounds.top)
347+
if (this.view.y <= this.bounds.top * this.scale.y)
348348
{
349349
this.atLimit.y = true;
350-
this.view.y = this.bounds.top;
350+
this.view.y = this.bounds.top * this.scale.y;
351351
}
352352

353-
if (this.view.bottom >= this.bounds.bottom)
353+
if (this.view.bottom >= this.bounds.bottom * this.scale.y)
354354
{
355355
this.atLimit.y = true;
356-
this.view.y = this.bounds.bottom - this.height;
356+
this.view.y = (this.bounds.bottom * this.scale.y) - this.height;
357357
}
358358

359359
},

0 commit comments

Comments
 (0)