Skip to content

Commit adf6543

Browse files
committed
Add asDegrees to Point.setToPolar
1 parent 27198da commit adf6543

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/geom/Point.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ Phaser.Point.prototype = {
107107
* Sets the `x` and `y` values of this Point object from a given polar coordinate.
108108
*
109109
* @method Phaser.Point#setToPolar
110-
* @param {number} azimuth - The angular coordinate, in radians.
110+
* @param {number} azimuth - The angular coordinate, in radians (unless `asDegrees`).
111111
* @param {number} [radius=1] - The radial coordinate (length).
112+
* @param {boolean} [asDegrees=false] - True if `azimuth` is in degrees.
112113
* @return {Phaser.Point} This Point object. Useful for chaining method calls.
113114
*/
114-
setToPolar: function(azimuth, radius) {
115+
setToPolar: function(azimuth, radius, asDegrees) {
115116

116117
if (radius == null) { radius = 1; }
118+
if (asDegrees) { azimuth = Phaser.Math.degToRad(azimuth); }
117119

118120
return this.setTo(Math.cos(azimuth) * radius, Math.sin(azimuth) * radius);
119121

src/physics/arcade/World.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ Phaser.Physics.Arcade.prototype = {
18211821
if (speed === undefined) { speed = 60; }
18221822
point = point || new Phaser.Point();
18231823

1824-
return point.setToPolar(Phaser.Math.degToRad(angle), speed);
1824+
return point.setToPolar(angle, speed, true);
18251825

18261826
},
18271827

typescript/phaser.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3981,7 +3981,7 @@ declare module Phaser {
39813981
set(x: number, y?: number): Phaser.Point;
39823982
setMagnitude(magnitude: number): Phaser.Point;
39833983
setTo(x: number, y?: number): Phaser.Point;
3984-
setToPolar(azimuth: number, radius?: number): Phaser.Point;
3984+
setToPolar(azimuth: number, radius?: number, asDegrees?: boolean): Phaser.Point;
39853985
subtract(x: number, y: number): Phaser.Point;
39863986
toString(): string;
39873987

0 commit comments

Comments
 (0)