Skip to content

Commit 4903e47

Browse files
committed
Rectangle.topRight returns a Point object that represents the top-right coordinate of the Rectangle.
1 parent 72c0f50 commit 4903e47

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Version 2.1.0 - "Cairhien" - -in development-
110110
* Rectangle.centerOn(x,y) allows you to quickly center a Rectangle on the given coordinates.
111111
* Group.addMultiple allows you to pass an array of game objects and they'll all be added to the Group in turn.
112112
* The StateManager will now check if a State has a method called `resize`. If it does, and if the game is running in the RESIZE Scale Mode then this method will be called whenever the game resizes. It will be passed two parameters: `width` and `height` that will match the games new dimensions. Resizing can happen as a result of either the parent container changing shape, or the browser window resizing.
113+
* Rectangle.topRight returns a Point object that represents the top-right coordinate of the Rectangle.
113114

114115
### Updates
115116

src/geom/Rectangle.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,24 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
553553

554554
});
555555

556+
/**
557+
* The location of the Rectangles top right corner as a Point object.
558+
* @name Phaser.Rectangle#topRight
559+
* @property {Phaser.Point} topRight - The location of the Rectangles top left corner as a Point object.
560+
*/
561+
Object.defineProperty(Phaser.Rectangle.prototype, "topRight", {
562+
563+
get: function () {
564+
return new Phaser.Point(this.x + this.width, this.y);
565+
},
566+
567+
set: function (value) {
568+
this.right = value.x;
569+
this.y = value.y;
570+
}
571+
572+
});
573+
556574
/**
557575
* Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0.
558576
* If set to true then all of the Rectangle properties are set to 0.

0 commit comments

Comments
 (0)