Skip to content

@vaguevoid/fiasco / ecs/components / CircleCollider

Type Alias: CircleCollider

CircleCollider = Component

Defined in: src/ecs/components.ts:655

A component for detecting 2D collisions with other CircleColliders.

Attach this component to any entity and get notified if it collides via events.

ts
import { Query, Transform, CircleCollider, SystemOnce, EventReader, Events } from '@vaguevoid/fiasco'
import { Components } from '../.fiasco/generated'

function system(): SystemOnce {
  engine.spawn([
    new Components.Camera(),
    new Components.Transform(),
    new Components.CircleCollider()
  ])
}

function system2(collisions: EventReader<Events.Physics.CircleCollision>) {
  for (const collision of collisions) {
    // despawn anything that collides
    engine.despawn(collision.entities(0)!)
    engine.despawn(collision.entities(1)!)
  }
}