From ee1df55d84cdea33bf2910050b73532036fa2075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darek=20Zieli=C5=84ski?= Date: Mon, 14 Jul 2014 20:03:34 +0200 Subject: [PATCH] Added position Point object for quick x/y coordinates access. --- src/core/Camera.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/core/Camera.js b/src/core/Camera.js index 4e496d21a..e4169f102 100644 --- a/src/core/Camera.js +++ b/src/core/Camera.js @@ -406,6 +406,30 @@ Object.defineProperty(Phaser.Camera.prototype, "y", { }); +/** +* The Cameras position. This value is automatically clamped if it falls outside of the World bounds. +* @name Phaser.Camera#position +* @property {Phaser.Point} position - Gets or sets the cameras xy position using Phaser.Point object. +*/ +Object.defineProperty(Phaser.Camera.prototype, "position", { + + get: function () { + return new Phaser.Point(this.view.centerX, this.view.centerY); + }, + + set: function (value) { + + this.view.x = value.x; + this.view.y = value.y; + + if (this.bounds) + { + this.checkBounds(); + } + } + +}); + /** * The Cameras width. By default this is the same as the Game size and should not be adjusted for now. * @name Phaser.Camera#width