Skip to content

Commit ee1df55

Browse files
author
Darek Zieliński
committed
Added position Point object for quick x/y coordinates access.
1 parent ff5dda7 commit ee1df55

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/core/Camera.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,30 @@ Object.defineProperty(Phaser.Camera.prototype, "y", {
406406

407407
});
408408

409+
/**
410+
* The Cameras position. This value is automatically clamped if it falls outside of the World bounds.
411+
* @name Phaser.Camera#position
412+
* @property {Phaser.Point} position - Gets or sets the cameras xy position using Phaser.Point object.
413+
*/
414+
Object.defineProperty(Phaser.Camera.prototype, "position", {
415+
416+
get: function () {
417+
return new Phaser.Point(this.view.centerX, this.view.centerY);
418+
},
419+
420+
set: function (value) {
421+
422+
this.view.x = value.x;
423+
this.view.y = value.y;
424+
425+
if (this.bounds)
426+
{
427+
this.checkBounds();
428+
}
429+
}
430+
431+
});
432+
409433
/**
410434
* The Cameras width. By default this is the same as the Game size and should not be adjusted for now.
411435
* @name Phaser.Camera#width

0 commit comments

Comments
 (0)