Options
All
  • Public
  • Public/Protected
  • All
Menu

Edge is a single line collision shape to create collisions with a single line.

Example:

Edge Collision Shape

Excalibur has a Shape static helper to create edges for collisions in your game.

The default shape for a collider is a box, however a custom edge shape and Collider can be created for an actor body.

Edges are useful for creating walls, barriers, or platforms in your game.

Keep in mind, edges are defined local to the body or actor. Meaning that the edge defined below starts at ex.Vector(100, 100) and goes to ex.Vector(130, 400) in world space. It is recommended when defining edges to leave the first coordinate ex.Vector.Zero to avoid confusion.

const wall = new ex.Actor({
  pos: new ex.Vector(100, 300),
  color: ex.Color.Blue,
  body: new ex.Body({
    collider: new ex.Collider({
      shape: ex.Shape.Edge(new ex.Vector.Zero(), new ex.Vector(30, 100))
    })
  })
});

Hierarchy

  • Edge

Implements

Index

Constructors

constructor

Properties

begin

begin: Vector

body

body: Body

Optional collider

collider: Collider

end

end: Vector

offset

offset: Vector

Accessors

axes

bounds

center

inertia

  • get inertia(): number

localBounds

worldPos

Methods

asLine

asLocalLine

  • asLocalLine(): Line

clone

collide

contains

  • contains(): boolean

debugDraw

  • debugDraw(ctx: CanvasRenderingContext2D, color?: Color): void

draw

  • draw(ctx: CanvasRenderingContext2D, color?: Color, pos?: Vector): void

getClosestLineBetween

getFurthestPoint

getLength

  • getLength(): number

getSlope

project

rayCast

recalc

  • recalc(): void