Constructor
new Velocity(x, y)
Creates a new Velocity object.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Velocity in x direction. |
y |
number | Velocity in y direction. |
- Source:
Extends
Members
acceleration :rune.geom.Vector2D
Acceleration acts as gravity; it is a constant force that can affect the
object in the x and / or y direction. If acceleration is set, the object
is moved by the force of acceleration for each update.
Type:
- Default Value:
- new rune.geom.Vector2D(0, 0)
- Source:
angular :number
The object's rotation speed, stated in degrees per tick / frame.
Type:
- number
- Default Value:
- 0.0
- Source:
angularAcceleration :number
Constant force that affects the object's rotation, this property
basically acts as gravity for rotation. If the property is set, the
object is forced to rotate.
Type:
- number
- Default Value:
- 0.0
- Source:
angularDrag :number
Force that counteracts the rotational velocity when the rotation lacks
acceleration, ie force that slows down the rotation.
Type:
- number
- Default Value:
- 0.0
- Source:
angularMax :number
Limits rotation to a maximum speed.
Type:
- number
- Default Value:
- 100
- Source:
drag :rune.geom.Vector2D
Power that counteracts the velocity of the object. This force is applied
only when the object is not accelerating. If set, the object loses its
velocity over time.
Type:
- Default Value:
- new rune.geom.Vector2D(0, 0)
- Source:
max :rune.geom.Vector2D
Limits the velocity of the object in the x and y direction to a maximum
value.
Type:
- Default Value:
- new rune.geom.Vector2D(100, 100)
- Source:
x :number
The horizontal coordinate of the point. The default value is 0.
Type:
- number
- Overrides:
- Source:
y :number
The vertical coordinate of the point. The default value is 0.
Type:
- number
- Overrides:
- Source:
Methods
abs() → {rune.geom.Vector2D}
Set the vector axes values to absolute values.
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
add(vector) → {rune.geom.Vector2D}
Adds the argument vector to this vector.
Parameters:
| Name | Type | Description |
|---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
angleTo(target) → {number}
Returns the direction from this point to a target in radians, between -pi
and pi. Zero points along positive x. With screen coordinates, positive
angles turn toward positive y. Neither point is modified.
Returns zero when both points have the same coordinates.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
rune.geom.Point | Target point. |
- Inherited From:
- Source:
Returns:
Direction to the target in radians.
- Type
- number
copyFrom(point) → {rune.geom.Point}
Copies the coordinates of the specified point to this point.
Parameters:
| Name | Type | Description |
|---|---|---|
point |
rune.geom.Point | The point to copy coordinates from. |
- Inherited From:
- Source:
Returns:
This point.
- Type
- rune.geom.Point
cross(vector) → {number}
Returns the cross product of this vector by another.
Parameters:
| Name | Type | Description |
|---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Inherited From:
- Source:
Returns:
- Type
- number
distance(point) → {number}
Returns the distance between the current and specified point.
Parameters:
| Name | Type | Description |
|---|---|---|
point |
rune.geom.Point | The specified point. |
- Inherited From:
- Source:
Returns:
- Type
- number
distanceSquared(point) → {number}
Returns the squared distance between the current and specified point without
calculating a square root. Compare the result against a squared distance.
Parameters:
| Name | Type | Description |
|---|---|---|
point |
rune.geom.Point | The specified point. |
- Inherited From:
- Source:
Returns:
The squared distance between the points.
- Type
- number
divide(value) → {rune.geom.Vector2D}
Divides this vector by another vector, or by a number specified as a
floating point number.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
rune.geom.Vector2D | number | The value to divide by. |
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
dot(vector) → {number}
Returns the dot product of this vector by another.
Parameters:
| Name | Type | Description |
|---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Inherited From:
- Source:
Returns:
- Type
- number
equals(vector) → {boolean}
Determine if the specified vector is equal to the current vector.
Parameters:
| Name | Type | Description |
|---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Inherited From:
- Source:
Returns:
- Type
- boolean
interpolate(point, fractionopt, outputopt) → {rune.geom.Point}
Determines a point between two specified points. The parameter fraction
determines where the new interpolated point is located relative to the two
end points.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
point |
rune.geom.Point | The second point. | |
fraction |
number |
<optional> |
The level of interpolation between the two points. |
output |
rune.geom.Point |
<optional> |
Save results to this object. |
- Inherited From:
- Source:
Returns:
The new, interpolated point.
- Type
- rune.geom.Point
magnitude(squaredopt) → {number}
Returns the magnitude (length) of this vector.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
squared |
boolean |
<optional> |
Request squared magnitude. |
- Inherited From:
- Source:
Returns:
- Type
- number
moveTowards(target, distance) → {rune.geom.Point}
Moves this point toward a target by at most the specified distance without
passing it. The target is not modified. A distance of zero or less leaves
this point unchanged. All coordinates and the distance use the same units.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
rune.geom.Point | Target point. |
distance |
number | Maximum distance to move for this call. |
- Inherited From:
- Source:
Returns:
This point.
- Type
- rune.geom.Point
multiply(value) → {rune.geom.Vector2D}
Multiplies this vector by another vector, or by a number specified as a
floating point number.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
rune.geom.Vector2D | number | The value to multiply by. |
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
normalize(scaleopt) → {rune.geom.Vector2D}
Scales the line segment between (0,0) and the current vector to a set length.
A scale of zero clears a nonzero vector. A zero vector remains unchanged.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
scale |
number |
<optional> |
1 | The scaling value. |
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
reverse() → {rune.geom.Vector2D}
Reverses this vector i.e multiplies it by -1.
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
rotate(rads) → {rune.geom.Vector2D}
Rotates the vector with specified radians.
Parameters:
| Name | Type | Description |
|---|---|---|
rads |
number | Amount of rotation specified in radians. |
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
round(n) → {rune.geom.Vector2D}
Rotates the vector by provided radians.
Parameters:
| Name | Type | Description |
|---|---|---|
n |
number | Number of decimals for precision. |
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
set(x, y) → {rune.geom.Point}
Sets the horizontal and vertical coordinates of this point.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | The horizontal coordinate. |
y |
number | The vertical coordinate. |
- Inherited From:
- Source:
Returns:
This point.
- Type
- rune.geom.Point
setFromAngle(angle, speed) → {rune.geom.Vector2D}
Sets this vector from an angle in radians and a magnitude. Zero radians
points right; positive angles turn clockwise in screen coordinates.
A negative magnitude reverses the direction. No new object is allocated.
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
number | Direction in radians. |
speed |
number | Magnitude in the vector's existing units. |
- Inherited From:
- Source:
Returns:
This vector.
- Type
- rune.geom.Vector2D
setTowards(source, target, speed) → {rune.geom.Vector2D}
Sets this vector toward a target from a source position, with the specified
magnitude. Coincident positions produce a zero vector. A negative magnitude
points away from the target. No new object is allocated or position moved.
Read both positions before writing so either may also be this vector.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
rune.geom.Point | Starting position. |
target |
rune.geom.Point | Target position. |
speed |
number | Magnitude in the vector's existing units. |
- Inherited From:
- Source:
Returns:
This vector.
- Type
- rune.geom.Vector2D
subtract(vector) → {rune.geom.Vector2D}
Subtracts the argument vector from this vector.
Parameters:
| Name | Type | Description |
|---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Inherited From:
- Source:
Returns:
- Type
- rune.geom.Vector2D
toString() → {string}
Returns a string that contains the values of the x and y coordinates.
- Inherited From:
- Source:
Returns:
The string representation of the coordinates.
- Type
- string