Skip to content

Commit bdcc9fc

Browse files
committed
Updated jsdocs re: Image/Sprite.crop (phaserjs#820)
1 parent cc9a234 commit bdcc9fc

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/gameobjects/Image.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,13 @@ Phaser.Image.prototype.loadTexture = function (key, frame) {
285285
/**
286286
* Crop allows you to crop the texture used to display this Image.
287287
* Cropping takes place from the top-left of the Image and can be modified in real-time by providing an updated rectangle object.
288+
* The rectangle object given to this method can be either a Phaser.Rectangle or any object so long as it has public x, y, width and height properties.
289+
* Please note that the rectangle object given is not duplicated by this method, but rather the Image uses a reference to the rectangle.
290+
* Keep this in mind if assigning a rectangle in a for-loop, or when cleaning up for garbage collection.
288291
*
289292
* @method Phaser.Image#crop
290293
* @memberof Phaser.Image
291-
* @param {Phaser.Rectangle} rect - The Rectangle to crop the Image to. Pass null or no parameters to clear a previously set crop rectangle.
294+
* @param {Phaser.Rectangle|object} rect - The Rectangle to crop the Image to. Pass null or no parameters to clear a previously set crop rectangle.
292295
*/
293296
Phaser.Image.prototype.crop = function(rect) {
294297

src/gameobjects/Sprite.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame) {
410410
* Crop allows you to crop the texture used to display this Sprite.
411411
* Cropping takes place from the top-left of the Sprite and can be modified in real-time by providing an updated rectangle object.
412412
* Note that cropping a Sprite will reset its animation to the first frame. You cannot currently crop an animated Sprite.
413+
* The rectangle object given to this method can be either a Phaser.Rectangle or any object so long as it has public x, y, width and height properties.
414+
* Please note that the rectangle object given is not duplicated by this method, but rather the Image uses a reference to the rectangle.
415+
* Keep this in mind if assigning a rectangle in a for-loop, or when cleaning up for garbage collection.
413416
*
414417
* @method Phaser.Sprite#crop
415418
* @memberof Phaser.Sprite

0 commit comments

Comments
 (0)