mirror of
https://github.com/photonstorm/phaser
synced 2024-12-18 09:03:29 +00:00
4de95c09b5
- Required changes for documentation to show up correctly - Uses multiple @extends, which currently [mostly] works in jsdoc and like closure compiler
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
/**
|
|
* Overlap Component Features.
|
|
*
|
|
* @class
|
|
*/
|
|
Phaser.Component.Overlap = function () {};
|
|
|
|
Phaser.Component.Overlap.prototype = {
|
|
|
|
/**
|
|
* Checks to see if the bounds of this Sprite overlaps with the bounds of the given Display Object, which can be a Sprite, Image, TileSprite or anything that extends those such as a Button.
|
|
* This check ignores the Sprites hitArea property and runs a Sprite.getBounds comparison on both objects to determine the result.
|
|
* Therefore it's relatively expensive to use in large quantities (i.e. with lots of Sprites at a high frequency), but should be fine for low-volume testing where physics isn't required.
|
|
*
|
|
* @method
|
|
* @param {Phaser.Sprite|Phaser.Image|Phaser.TileSprite|Phaser.Button|PIXI.DisplayObject} displayObject - The display object to check against.
|
|
* @return {boolean} True if the bounds of this Sprite intersects at any point with the bounds of the given display object.
|
|
*/
|
|
overlap: function (displayObject) {
|
|
|
|
return Phaser.Rectangle.intersects(this.getBounds(), displayObject.getBounds());
|
|
|
|
}
|
|
|
|
};
|