Skip to content

Commit 524892f

Browse files
committed
Fixed angle value and facing direction
1 parent a74616b commit 524892f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/input/Pointer.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ var Pointer = new Class({
151151
/**
152152
* The current angle the Pointer is moving, in radians, based on its previous and current position.
153153
*
154+
* The angle is based on the old position facing to the current position.
155+
*
154156
* This property is updated whenever the Pointer moves, regardless of any button states. In other words,
155157
* it changes based on movement alone - a button doesn't have to be pressed first.
156158
*
@@ -159,7 +161,7 @@ var Pointer = new Class({
159161
* @readonly
160162
* @since 3.16.0
161163
*/
162-
this.angle = new Vector2();
164+
this.angle = 0;
163165

164166
/**
165167
* The distance the Pointer has moved, based on its previous and current position.
@@ -542,7 +544,7 @@ var Pointer = new Class({
542544

543545
this.velocity.set(dx, dy);
544546

545-
this.angle = Math.atan2(dy, dx);
547+
this.angle = Angle(vx, vy, cx, cy);
546548

547549
this.distance = Math.sqrt(dx * dx + dy * dy);
548550
},
@@ -978,6 +980,8 @@ var Pointer = new Class({
978980
* If no button is held down, it will return the last recorded angle, based on where
979981
* the Pointer was when the button was released.
980982
*
983+
* The angle is based on the old position facing to the current position.
984+
*
981985
* If you wish to get the current angle, based on the velocity of the Pointer, then
982986
* see the `Pointer.angle` property.
983987
*
@@ -990,11 +994,11 @@ var Pointer = new Class({
990994
{
991995
if (this.isDown)
992996
{
993-
return Angle(this.x, this.y, this.downX, this.downY);
997+
return Angle(this.downX, this.downY, this.x, this.y);
994998
}
995999
else
9961000
{
997-
return Angle(this.upX, this.upY, this.downX, this.downY);
1001+
return Angle(this.downX, this.downY, this.upX, this.upY);
9981002
}
9991003
},
10001004

0 commit comments

Comments
 (0)