mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 22:48:34 +00:00
Added Vector2.angle method
This commit is contained in:
parent
9d3c80ab0c
commit
aab4896582
1 changed files with 14 additions and 0 deletions
|
@ -50,6 +50,20 @@ var Vector2 = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
angle: function () {
|
||||
|
||||
// computes the angle in radians with respect to the positive x-axis
|
||||
|
||||
var angle = Math.atan2(this.y, this.x);
|
||||
|
||||
if (angle < 0)
|
||||
{
|
||||
angle += 2 * Math.PI;
|
||||
}
|
||||
|
||||
return angle;
|
||||
},
|
||||
|
||||
add: function (src)
|
||||
{
|
||||
this.x += src.x;
|
||||
|
|
Loading…
Add table
Reference in a new issue