Skip to content

Commit 05688ac

Browse files
committed
Tile.GetBounds
1 parent 8b8601b commit 05688ac

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/gameobjects/tilemap/Tile.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var Class = require('../../utils/Class');
22
var Components = require('../components');
3+
var Rectangle = require('../../geom/rectangle');
34

45
var Tile = new Class({
56

@@ -312,6 +313,25 @@ var Tile = new Class({
312313
: this.getTop(camera) + this.height;
313314
},
314315

316+
317+
/**
318+
* Gets the world rectangle bounding box for the tile, factoring in the layer's position,
319+
* scale and scroll.
320+
* @param {Camera} [camera=main camera] - [description]
321+
* @param {object} [output] - [description]
322+
* @returns {Phaser.Geom.Rectangle|object}
323+
*/
324+
getBounds: function (camera, output)
325+
{
326+
if (output === undefined) { output = new Rectangle(); }
327+
328+
output.x = this.getLeft();
329+
output.y = this.getTop();
330+
output.width = this.getRight() - output.x;
331+
output.height = this.getBottom() - output.y;
332+
return output;
333+
},
334+
315335
/**
316336
* Gets the world X position of the center of the tile, factoring in the layer's position,
317337
* scale and scroll.

0 commit comments

Comments
 (0)