Class: Ray
Defined in: physics/raycast.ts:68
Ray class that represents a ray in 2D space.
Constructors
Constructor
new Ray(
start,end):Ray
Defined in: physics/raycast.ts:78
Creates a new Ray object.
Parameters
start
The starting point of the ray
end
The ending point of the ray
Returns
Ray
Properties
end
end:
Vector2
Defined in: physics/raycast.ts:70
start
start:
Vector2
Defined in: physics/raycast.ts:69
vertices
vertices:
Vector2[] =[]
Defined in: physics/raycast.ts:71
Accessors
difference
Get Signature
get difference():
Vector2
Defined in: physics/raycast.ts:299
Returns
isHorizontal
Get Signature
get isHorizontal():
boolean
Defined in: physics/raycast.ts:314
Returns
boolean
isVertical
Get Signature
get isVertical():
boolean
Defined in: physics/raycast.ts:318
Returns
boolean
offsetY
Get Signature
get offsetY():
number
Defined in: physics/raycast.ts:307
Returns
number
slope
Get Signature
get slope():
number
Defined in: physics/raycast.ts:303
Returns
number
Methods
calculateNormal()
calculateNormal(
referencePoint):Vector2
Defined in: physics/raycast.ts:281
Calculates the normal vector of the ray at the specified reference point.
Parameters
referencePoint
The reference point to calculate the normal vector from
Returns
The normal vector of the ray at the specified reference point
pointInBounds()
pointInBounds(
point):boolean
Defined in: physics/raycast.ts:263
Checks if a point is within the bounds of the ray.
Parameters
point
The point to check
Returns
boolean
True if the point is within the bounds of the ray, false otherwise
xValueAt()
xValueAt(
y):number
Defined in: physics/raycast.ts:251
Returns the x value on the ray at the specified y.
Parameters
y
number
The y value to check
Returns
number
The x value on the ray at the specified y
yValueAt()
yValueAt(
x):number
Defined in: physics/raycast.ts:239
Returns the y value on the ray at the specified x.
Parameters
x
number
The x value to check
Returns
number
The y value on the ray at the specified x
bodyCollisions()
staticbodyCollisions(rayA,body):RaycastCollision[]
Defined in: physics/raycast.ts:173
Finds every point at which a ray intersects a body.
Parameters
rayA
Ray
The ray to test.
body
The body to test against.
Returns
The collisions between the ray and the body.
bodyEdges()
staticbodyEdges(body):Ray[]
Defined in: physics/raycast.ts:141
Computes the world-space edges of a polygon body as a list of rays.
Parameters
body
The body to compute edges for.
Returns
Ray[]
The world-space edges of the body, one ray per edge.
Throws
An error if the body's shape is not a polygon.
collisionPoint()
staticcollisionPoint(rayA,rayB):null|Vector2
Defined in: physics/raycast.ts:117
Parameters
rayA
Ray
rayB
Ray
Returns
null | Vector2
intersect()
staticintersect(rayA,rayB):null|Vector2
Defined in: physics/raycast.ts:83
Parameters
rayA
Ray
rayB
Ray
Returns
null | Vector2