Vector

Module: engine.geometry

Basic vector class with two values.

new game.Vector([x], [y])

Parameters:

  • x Number (optional)
  • y Number (optional)

Properties

x Number (Default: 0)

(No description yet)

y Number (Default: 0)

(No description yet)

Methods

add(x, [y])

Add to vector values.

Parameters:

  • x Number|Vector
  • y Number (optional)
angle([vector]) Number

Get vector angle or angle between two vectors.

Parameters:

  • vector Vector (optional)
angleFromOrigin(vector) Number

Get angle between two vectors from origin.

Parameters:

  • vector Vector
clone() Vector

Clone vector.

compare(vector) Boolean

Is values same with another vector.

Parameters:

  • vector Vector
copy(vector)

Copy values from another vector.

Parameters:

  • vector Vector
distance(x, [y])

Get distance between two points.

Parameters:

  • x Number|Vector
  • y Number (optional)
divide(x, [y])

Divide vector values.

Parameters:

  • x Number|Vector
  • y Number (optional)
dot([vector]) Number

Get dot of vector.

Parameters:

  • vector Vector (optional)
dotNormalized([vector]) Number

Get normalized dot of vector.

Parameters:

  • vector Vector (optional)
length() Number

Get length of vector.

limit(vector)

Limit vector values.

Parameters:

  • vector Vector
move(distance, angle)

Change values based on distance and angle.

Parameters:

  • distance Number
  • angle Vector|Number
multiply(x, [y])

Multiply vector values.

Parameters:

  • x Number|Vector
  • y Number (optional)
multiplyAdd(x, [y])

Multiply and add vector values.

Parameters:

  • x Number|Vector
  • y Number (optional)
normalize()

Normalize vector.

rotate(angle)

Rotate vector in radians.

Parameters:

  • angle Number
round([precision])

Round vector values.

Parameters:

  • precision Number (optional)
set(x, [y])

Set vector values.

Parameters:

  • x Number
  • y Number (optional)
subtract(x, [y])

Subtract from vector values.

Parameters:

  • x Number|Vector
  • y Number (optional)
swap(target)

Swap vector values with another vector.

Parameters:

  • target Vector