Merge pull request #1015 from Zielak/dev

Phaser.Camera.position for quick access
This commit is contained in:
Richard Davey 2014-08-28 02:02:40 +01:00
commit 50179d76fb

View file

@ -86,6 +86,13 @@ Phaser.Camera = function (game, id, x, y, width, height) {
*/
this._edge = 0;
/**
* @property {Phaser.Point} position - Current position of the camera in world.
* @private
* @default
*/
this._position = new Phaser.Point();
/**
* @property {PIXI.DisplayObject} displayObject - The display object to which all game objects are added. Set by World.boot
*/
@ -406,6 +413,31 @@ 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 () {
this._position.set(this.view.centerX, this.view.centerY);
return this._position;
},
set: function (value) {
if (typeof value.x !== "undefined") { this.view.x = value.x; }
if (typeof value.y !== "undefined") { 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