phaser/src/geom/intersects/CircleToCircle.js

26 lines
814 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2019-01-15 16:20:22 +00:00
* @copyright 2019 Photon Storm Ltd.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2018-02-12 16:01:20 +00:00
*/
var DistanceBetween = require('../../math/distance/DistanceBetween');
2017-10-13 13:11:54 +00:00
/**
* Checks if two Circles intersect.
2017-10-13 13:11:54 +00:00
*
* @function Phaser.Geom.Intersects.CircleToCircle
* @since 3.0.0
*
* @param {Phaser.Geom.Circle} circleA - The first Circle to check for intersection.
* @param {Phaser.Geom.Circle} circleB - The second Circle to check for intersection.
2017-10-13 13:11:54 +00:00
*
* @return {boolean} `true` if the two Circles intersect, otherwise `false`.
2017-10-13 13:11:54 +00:00
*/
2017-01-04 00:21:26 +00:00
var CircleToCircle = function (circleA, circleB)
{
return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius));
};
2017-01-04 00:21:26 +00:00
module.exports = CircleToCircle;