class FlxAngle
package flixel.math
A set of functions related to angle calculations. In degrees: (down = 90, right = 0, up = -90)
Note: in Flixel 5.0.0 all angle-related tools were changed so that 0 degrees points right, instead of up
See also:
Static variables
Static methods
staticangleBetween(SpriteA:FlxSprite, SpriteB:FlxSprite, AsDegrees:Bool = false):Float
Find the angle between the two FlxSprite, taking their x/y and origin into account.
Parameters:
SpriteA | The FlxSprite to test from |
|---|---|
SpriteB | The FlxSprite to test to |
AsDegrees | If you need the value in degrees instead of radians, set to true |
Returns:
The angle (in radians unless asDegrees is true)
staticangleBetweenMouse(Object:FlxObject, AsDegrees:Bool = false):Float
Find the angle between an FlxSprite and the mouse, taking their screen x/y and origin into account.
Parameters:
Object | The FlxObject to test from |
|---|---|
AsDegrees | If you need the value in degrees instead of radians, set to true |
Returns:
The angle (in radians unless AsDegrees is true)
staticangleBetweenPoint(Sprite:FlxSprite, Target:FlxPoint, AsDegrees:Bool = false):Float
Find the angle between an FlxSprite and an FlxPoint. The source sprite takes its x/y and origin into account.
Parameters:
Sprite | The FlxSprite to test from |
|---|---|
Target | The FlxPoint to angle the FlxSprite towards |
AsDegrees | If you need the value in degrees instead of radians, set to true |
Returns:
The angle (in radians unless AsDegrees is true)
staticangleBetweenTouch(Object:FlxObject, Touch:FlxTouch, AsDegrees:Bool = false):Float
Find the angle between an FlxSprite and a FlxTouch, taking their screen x/y and origin into account.
Parameters:
Object | The FlxObject to test from |
|---|---|
Touch | The FlxTouch to test to |
AsDegrees | If you need the value in degrees instead of radians, set to true |
Returns:
The angle (in radians unless AsDegrees is true)
staticangleFromFacing(Facing:FlxDirectionFlags, AsDegrees:Bool = false):Float
Translate an object's facing to angle.
Parameters:
FacingBitmask | Bitmask from which to calculate the angle, as in FlxSprite::facing |
|---|---|
AsDegrees | If you need the value in degrees instead of radians, set to true |
Returns:
The angle (in radians unless AsDegrees is true)
staticinlineangleFromOrigin(x:Float, y:Float, asDegrees:Bool = false):Float
Calculates the angle from (0, 0) to (x, y)
Parameters:
x | The x distance from the origin |
|---|---|
y | The y distance from the origin |
asDegrees | If true, it gives the value in degrees |
Returns:
The angle, either in degrees, between -180 and 180 or in radians, between -PI and PI
staticinlineasDegrees(radians:Float):Float
Converts a Radian value into a Degree Converts the radians value into degrees and returns
Parameters:
radians | The value in radians |
|---|
Returns:
Degrees
staticinlineasRadians(degrees:Float):Float
Converts a Degrees value into a Radian Converts the degrees value into radians and returns
Parameters:
degrees | The value in degrees |
|---|
Returns:
Radians
staticinlinedegreesBetween(SpriteA:FlxSprite, SpriteB:FlxSprite):Float
Find the angle (in degrees) between the two FlxSprite, taking their x/y and origin into account.
Parameters:
SpriteA | The FlxSprite to test from |
|---|---|
SpriteB | The FlxSprite to test to |
Returns:
The angle in degrees
5.0.0
.staticinlinedegreesBetweenMouse(Object:FlxObject):Float
Find the angle (in degrees) between an FlxSprite and the mouse, taking their screen x/y and origin into account.
Parameters:
Object | The FlxObject to test from |
|---|
Returns:
The angle in degrees
5.0.0
.staticinlinedegreesBetweenPoint(Sprite:FlxSprite, Target:FlxPoint):Float
Find the angle (in degrees) between an FlxSprite and an FlxPoint. The source sprite takes its x/y and origin into account.
Parameters:
Sprite | The FlxSprite to test from |
|---|---|
Target | The FlxPoint to angle the FlxSprite towards |
Returns:
The angle in degrees
5.0.0
.staticinlinedegreesBetweenTouch(Object:FlxObject, Touch:FlxTouch):Float
Find the angle (in degrees) between an FlxSprite and a FlxTouch, taking their screen x/y and origin into account.
Parameters:
Object | The FlxObject to test from |
|---|---|
Touch | The FlxTouch to test to |
Returns:
The angle in degrees
5.0.0
.staticinlinedegreesFromOrigin(x:Float, y:Float):Float
Calculates the angle from (0, 0) to (x, y), in degrees
Parameters:
x | The x distance from the origin |
|---|---|
y | The y distance from the origin |
Returns:
The angle in degrees between -180 to 180
staticgetCartesianCoords(Radius:Float, Angle:Float, ?point:FlxPoint):FlxPoint
Convert polar coordinates (radius + angle) to cartesian coordinates (x + y)
Parameters:
Radius | The radius |
|---|---|
Angle | The angle, in degrees |
point | Optional FlxPoint if you don't want a new one created |
Returns:
The point in cartesian coords
staticgetPolarCoords(X:Float, Y:Float, ?point:FlxPoint):FlxPoint
Convert cartesian coordinates (x + y) to polar coordinates (radius + angle)
Parameters:
X | x position |
|---|---|
Y | y position |
point | Optional FlxPoint if you don't want a new one created |
Returns:
The point in polar coords (x = Radius, y = Angle (degrees))
staticinlineradiansBetween(SpriteA:FlxSprite, SpriteB:FlxSprite):Float
Find the angle (in radians) between the two FlxSprite, taking their x/y and origin into account.
Parameters:
SpriteA | The FlxSprite to test from |
|---|---|
SpriteB | The FlxSprite to test to |
Returns:
The angle in radians
5.0.0
.staticinlineradiansBetweenMouse(Object:FlxObject):Float
Find the angle (in radians) between an FlxSprite and the mouse, taking their screen x/y and origin into account.
Parameters:
Object | The FlxObject to test from |
|---|
Returns:
The angle in radians
5.0.0
.staticinlineradiansBetweenPoint(Sprite:FlxSprite, Target:FlxPoint):Float
Find the angle (in radians) between an FlxSprite and an FlxPoint. The source sprite takes its x/y and origin into account.
Parameters:
Sprite | The FlxSprite to test from |
|---|---|
Target | The FlxPoint to angle the FlxSprite towards |
Returns:
The angle in radians
5.0.0
.staticinlineradiansBetweenTouch(Object:FlxObject, Touch:FlxTouch):Float
Find the angle (in radians) between an FlxSprite and a FlxTouch, taking their screen x/y and origin into account.
Parameters:
Object | The FlxObject to test from |
|---|---|
Touch | The FlxTouch to test to |
Returns:
The angle in radians
5.0.0
.staticinlineradiansFromOrigin(x:Float, y:Float):Float
Calculates the angle from (0, 0) to (x, y), in radians
Parameters:
x | The x distance from the origin |
|---|---|
y | The y distance from the origin |
Returns:
The angle in radians between -PI to PI
staticwrapAngle(angle:Float):Float
Keeps an angle value between -180 and +180 by wrapping it e.g an angle of +270 will be converted to -90 Should be called whenever the angle is updated on a FlxSprite to stop it from going insane.
Parameters:
angle | The angle value to check |
|---|
Returns:
The new angle value, returns the same as the input angle if it was within bounds