Options
All
  • Public
  • Public/Protected
  • All
Menu

This is a circle collision shape for the excalibur rigid body physics simulation

Example:

Circle Collision Shape

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

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

This example creates a circle of radius = 50.

const circle = new ex.Actor({
  pos: new ex.Vector(400, 400),
  color: ex.Color.Red,
  body: new ex.Body({
    collider: new ex.Collider({
      shape: ex.Shape.Circle(50)
      type: ex.CollisionType.Active;
    })
  })
});

Hierarchy

  • Circle

Implements

Index

Constructors

constructor

Properties

Optional collider

collider: Collider

The collider associated for this shape, if any.

offset

offset: Vector = Vector.Zero

Position of the circle relative to the collider, by default (0, 0) meaning the shape is positioned on top of the collider.

radius

radius: number

This is the radius of the circle

Accessors

axes

bounds

center

inertia

  • get inertia(): number

localBounds

worldPos

Methods

clone

collide

contains

  • contains(point: Vector): boolean

debugDraw

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

draw

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

getClosestLineBetween

getFurthestPoint

project

rayCast

recalc

  • recalc(): void

testSeparatingAxisTheorem