Skip to content

Commit 64ae6c6

Browse files
author
Darek Zieliński
committed
"Reuse a single Point object rather than creating a new one each time"
1 parent 852054b commit 64ae6c6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/core/Camera.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ Phaser.Camera = function (game, id, x, y, width, height) {
8686
*/
8787
this._edge = 0;
8888

89+
/**
90+
* @property {Phaser.Point} position - Current position of the camera in world.
91+
* @private
92+
* @default
93+
*/
94+
this._position = new Phaser.Point();
95+
8996
/**
9097
* @property {PIXI.DisplayObject} displayObject - The display object to which all game objects are added. Set by World.boot
9198
*/
@@ -414,7 +421,8 @@ Object.defineProperty(Phaser.Camera.prototype, "y", {
414421
Object.defineProperty(Phaser.Camera.prototype, "position", {
415422

416423
get: function () {
417-
return new Phaser.Point(this.view.centerX, this.view.centerY);
424+
this._position.set(this.view.centerX, this.view.centerY);
425+
return this._position;
418426
},
419427

420428
set: function (value) {

0 commit comments

Comments
 (0)