-
class Vector2:
Object
¶ -
x:
number
¶ The x component of the vector.
-
y:
number
¶ The y component of the vector.
-
__new(self:
Vector2
, x:number
, y:number
)¶ Constructor for Vector2 accepts two numbers, x and y. Both default to zero.
- Parameters:
x (
number
) – The x component of the vector.y (
number
) – The y component of the vector.
-
copy(self:
Vector2
, out:any
):Vector2
¶ Returns a copy of the vector.
- Returns:
_1 (
Vector2
) – A copy of the vector.
-
length(self:
Vector2
):number
¶ Returns the length of the vector.
- Returns:
_1 (
number
) – The length of the vector.
-
rotateClockwise(self:
Vector2
): (The:Vector2
)¶ Rotates the vector clockwise.
- Returns:
The (
Vector2
) – rotated vector.
-
staticmethod _hash(x:
integer
, y:integer
):integer
¶
-
staticmethod _unhash(hash:
number
):number
,integer
¶
-
distanceManhattan(self:
Vector2
, vec:Vector2
): (distance:number
)¶ Manhattan distance from another point.
-
distanceChebyshev(self:
Vector2
, vec:Vector2
): (distance:number
)¶ Chebyshev distance from another point.
-
getRange(
self:Vector2
,
vec:Vector2
,
type?: "4way" | "8way" | "chebyshev" | "euclidean" | "manhattan"
):number
¶ Gets the range, a ceil’d integer representing the number of tiles away the other vector is.
-
decompose(self:
Vector2
): (x:number
, y:number
)¶ Returns the x and y components of the vector separately. This allows you to access the individual components of the vector as separate values.
- Returns:
x (
number
) – The x component of the vector.y (
number
) – The y component of the vector.
-
compose(self:
Vector2
, x:number
, y:number
)¶ Overwrites the vector’s x and y components with new values. This updates the current vector to match the provided x and y values.
- Parameters:
x (
number
) – The new x component to set.y (
number
) – The new y component to set.
-
equals(self:
Vector2
, x:number
, y:number
): (equal:boolean
)¶ Checks equality against x and y components.
- Parameters:
x (
number
) – The x component to check.y (
number
) – The y component to check.
- Returns:
equal (
boolean
) – Whether the vector is equal to the given components.
Other members:
Inherited from
Object
:_serializationBlacklist
,adopt()
,assertType()
,className
,deserialize()
,extend()
,instanceOf()
,is()
,isInstance()
,mixin()
,prettyprint()
,serializationBlacklist
,serialize()
-
x: