2020-04-24 20:26:42 +00:00
|
|
|
/**
|
|
|
|
* @author samme
|
|
|
|
* @copyright 2020 Photon Storm Ltd.
|
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Position a `point` at the given `angle` and `distance` to (`x`, `y`).
|
|
|
|
*
|
|
|
|
* @function Phaser.Math.RotateTo
|
|
|
|
* @since 3.24.0
|
|
|
|
*
|
2020-07-14 08:45:30 +00:00
|
|
|
* @generic {Phaser.Types.Math.Vector2Like} T - [point,$return]
|
2020-04-24 20:26:42 +00:00
|
|
|
*
|
2020-07-14 08:45:30 +00:00
|
|
|
* @param {Phaser.Types.Math.Vector2Like} point - The point to be positioned.
|
2020-04-24 20:26:42 +00:00
|
|
|
* @param {number} x - The horizontal coordinate to position from.
|
|
|
|
* @param {number} y - The vertical coordinate to position from.
|
|
|
|
* @param {number} angle - The angle of rotation in radians.
|
|
|
|
* @param {number} distance - The distance from (x, y) to place the point at.
|
|
|
|
*
|
2020-07-14 08:45:30 +00:00
|
|
|
* @return {Phaser.Types.Math.Vector2Like} The given point.
|
2020-04-24 20:26:42 +00:00
|
|
|
*/
|
|
|
|
var RotateTo = function (point, x, y, angle, distance)
|
|
|
|
{
|
|
|
|
point.x = x + (distance * Math.cos(angle));
|
|
|
|
point.y = y + (distance * Math.sin(angle));
|
|
|
|
|
|
|
|
return point;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = RotateTo;
|