Skip to content

Commit 681d867

Browse files
committed
Rectangle.resize allows you to resize a Rectangle to the new given dimensions without altering its position.
1 parent 10a3df1 commit 681d867

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ Version 2.4 - "Katar" - in dev
301301
* Math.distanceSq will return the euclidean distance squared between the two given set of coordinates (thanks @jeremyosborne #1761 #1770)
302302
* StateManager.onStateChange is a new signal which is dispatched whenever the State changes from one to another. The callback you specify is sent two parameters: the string based key of the new state, and the second parameter is the string based key of the old / previous state.
303303
* onDragUpdate is a new signal that is dispatched whenever a Game object enabled for input and drag is moved by a pointer (i.e. during a drag event). See the `Phaser.InputHandler.enableDrag` docs for parameter details and the new Phaser Example.
304+
* Rectangle.resize allows you to resize a Rectangle to the new given dimensions without altering its position.
304305

305306
### Updates
306307

src/geom/Rectangle.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,24 @@ Phaser.Rectangle.prototype = {
238238

239239
},
240240

241+
/**
242+
* Resize the Rectangle by providing a new width and height.
243+
* The x and y positions remain unchanged.
244+
*
245+
* @method Phaser.Rectangle#resize
246+
* @param {number} width - The width of the Rectangle. Should always be either zero or a positive value.
247+
* @param {number} height - The height of the Rectangle. Should always be either zero or a positive value.
248+
* @return {Phaser.Rectangle} This Rectangle object
249+
*/
250+
resize: function (width, height) {
251+
252+
this.width = width;
253+
this.height = height;
254+
255+
return this;
256+
257+
},
258+
241259
/**
242260
* Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
243261
* @method Phaser.Rectangle#clone

typescript/phaser.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,9 @@ declare module Phaser {
24622462
videoStream: any;
24632463
isStreaming: boolean;
24642464
snapshot: Phaser.BitmapData;
2465+
retryLimit: number;
2466+
retry: number;
2467+
retryInterval: number;
24652468

24662469
onAccess: Phaser.Signal;
24672470
onError: Phaser.Signal;
@@ -3674,6 +3677,7 @@ declare module Phaser {
36743677
intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number): boolean;
36753678
offset(dx: number, dy: number): Phaser.Rectangle;
36763679
offsetPoint(point: Phaser.Point): Phaser.Rectangle;
3680+
resize(width: number, height: number): Phaser.Rectangle;
36773681
setTo(x: number, y: number, width: number, height: number): Phaser.Rectangle;
36783682
scale(x: number, y?: number): Phaser.Rectangle;
36793683
size(output?: Phaser.Point): Phaser.Point;

0 commit comments

Comments
 (0)