2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2022-02-28 14:29:51 +00:00
|
|
|
* @copyright 2022 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
|
|
|
*/
|
|
|
|
|
2017-10-13 13:11:54 +00:00
|
|
|
/**
|
2018-06-21 17:13:46 +00:00
|
|
|
* Set a line to a given position, angle and length.
|
2017-10-13 13:11:54 +00:00
|
|
|
*
|
|
|
|
* @function Phaser.Geom.Line.SetToAngle
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-27 13:27:08 +00:00
|
|
|
* @generic {Phaser.Geom.Line} O - [line,$return]
|
|
|
|
*
|
2018-06-21 17:13:46 +00:00
|
|
|
* @param {Phaser.Geom.Line} line - The line to set.
|
|
|
|
* @param {number} x - The horizontal start position of the line.
|
|
|
|
* @param {number} y - The vertical start position of the line.
|
|
|
|
* @param {number} angle - The angle of the line in radians.
|
|
|
|
* @param {number} length - The length of the line.
|
2017-10-13 13:11:54 +00:00
|
|
|
*
|
2018-06-21 17:13:46 +00:00
|
|
|
* @return {Phaser.Geom.Line} The updated line.
|
2017-10-13 13:11:54 +00:00
|
|
|
*/
|
2017-01-04 23:53:27 +00:00
|
|
|
var SetToAngle = function (line, x, y, angle, length)
|
|
|
|
{
|
|
|
|
line.x1 = x;
|
|
|
|
line.y1 = y;
|
|
|
|
|
|
|
|
line.x2 = x + (Math.cos(angle) * length);
|
|
|
|
line.y2 = y + (Math.sin(angle) * length);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = SetToAngle;
|