Skip to content

Commit da0bd86

Browse files
committed
Rectangle.ceil runs Math.ceil() on both the x and y values of the Rectangle.
Rectangle.ceilAll runs Math.ceil() on the x, y, width and height values of the Rectangle.
1 parent 8290e8c commit da0bd86

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ Version 2.4 - "Katar" - in dev
270270
* The Phaser.Matrix constructor now allows you to optionally set all Matrix properties on instantiation.
271271
* Text.setShadow has two new optional parameters: `shadowStroke` and `shadowFill`. These allow you to set if the drop shadow is applied to the Text stroke, the Text fill or both of them (thanks @qdrj #1766)
272272
* Text.shadowStroke and Text.shadowFill allow you to toggle if the drop shadow is applied to the Text stroke or fill independently.
273+
* ArcadePhysics.Body.syncBounds is a new property that if true forces the Body to check itself against the Sprite.getBounds() dimensions and adjust its width and height accordingly. If false it will compare its dimensions against the Sprite scale instead, and adjust its width height if the scale has changed. Typically you would need to enable `syncBounds` if your sprite is the child of a responsive display object such as a FlexLayer, or in any situation where the sprite scale doesn't change, but its parents scale is effecting the dimensions regardless.
274+
* Rectangle.ceil runs Math.ceil() on both the x and y values of the Rectangle.
275+
* Rectangle.ceilAll runs Math.ceil() on the x, y, width and height values of the Rectangle.
273276

274277
### Updates
275278

src/geom/Rectangle.js

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

161161
},
162162

163+
/**
164+
* Runs Math.ceil() on both the x and y values of this Rectangle.
165+
* @method Phaser.Rectangle#ceil
166+
*/
167+
ceil: function () {
168+
169+
this.x = Math.ceil(this.x);
170+
this.y = Math.ceil(this.y);
171+
172+
},
173+
174+
/**
175+
* Runs Math.ceil() on the x, y, width and height values of this Rectangle.
176+
* @method Phaser.Rectangle#ceilAll
177+
*/
178+
ceilAll: function () {
179+
180+
this.x = Math.ceil(this.x);
181+
this.y = Math.ceil(this.y);
182+
this.width = Math.ceil(this.width);
183+
this.height = Math.ceil(this.height);
184+
185+
},
186+
163187
/**
164188
* Copies the x, y, width and height properties from any given object to this Rectangle.
165189
* @method Phaser.Rectangle#copyFrom

0 commit comments

Comments
 (0)