📈Vector
A 2D Location system
class Vector(x: Number, y: Number)
If you want to store and do manipulations on 2D positions, use vector.
Example
var pos = new Vector( 10, 20 )
var subtract = new Vector( 0 , 10 )
pos.sub(subtract) // x: 10, y: 10
display.rect({ ...pos.get() , ...})
API
Initialise
(x: Number,y: Number)
get()
returns the x and y in a json object
set()
set this instance x and y.
parameter: x: Number, y: Number
add()
adds the provided vector to the current vector
parameter: Vector
sub()
subtracts the provided vector from the current vector
parameter: Vector
mul()
multiplies the provided vector on the current vector
parameter: Vector
div()
divides the provided vector from the current vector
parameter: Vector
X
Static variable you can set
Y
Static variable you can set
Last updated