mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 23:24:41 +00:00
Merge pull request #1015 from Zielak/dev
Phaser.Camera.position for quick access
This commit is contained in:
commit
50179d76fb
1 changed files with 32 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue