Skip to content

@fibbojs / 2d / FCollider

Class: FCollider

A 2d collider that can be attached to a component.

Accessors

component

get component(): undefined | FComponent

set component(component): void

Parameters

component: undefined | FComponent

Returns

undefined | FComponent

Defined in

2d/src/core/FCollider.ts:280

Constructors

new FCollider()

new FCollider(scene, options?): FCollider

Creates a collider for a given component.

Parameters

scene: FScene

The scene the collider belongs to.

options?: FColliderOptions

The options for the collider.

Returns

FCollider

Example

ts
const collider = new FCollider(scene, {
  position: { x: 0, y: 0 },
  scale: { x: 1, y: 1 },
  shape: FShapes.CIRCLE
})

Defined in

2d/src/core/FCollider.ts:71

Methods

__SET_POSITION__()

__SET_POSITION__(position): void

Set the position of the collider.

Parameters

position: FVector2

The new position of the collider.

Returns

void

Defined in

2d/src/core/FCollider.ts:243


__SET_ROTATION__()

__SET_ROTATION__(rotation): void

Set the rotation of the collider.

Parameters

rotation: number

The new rotation of the collider in degrees.

Returns

void

Defined in

2d/src/core/FCollider.ts:252


__SET_SCALE__()

__SET_SCALE__(scale): void

Set the scale of the collider.

Parameters

scale: FVector2

The new scale of the collider.

Returns

void

Defined in

2d/src/core/FCollider.ts:261


__UPDATE_POSITION__()

__UPDATE_POSITION__(initiator): void

Update the position of the collider according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the collider won't be considered as the initiator of the position update. This means the new position will be the position of the attached component, plus the offset. Setting this to true will propagate the event to other objects (component, sensor,...).

Returns

void

Defined in

2d/src/core/FCollider.ts:162


__UPDATE_ROTATION__()

__UPDATE_ROTATION__(initiator): void

Update the rotation of the collider according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the collider won't be considered as the initiator of the rotation update. This means the new rotation will be the rotation of the attached component, plus the offset. Setting this to true will propagate the event to other objects (component, sensor,...).

Returns

void

Defined in

2d/src/core/FCollider.ts:191


__UPDATE_SCALE__()

__UPDATE_SCALE__(initiator): void

Update the scale of the collider according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the collider won't be considered as the initiator of the scale update. This means the new scale will be the scale of the attached component, plus the offset. Setting this to true will propagate the event to other objects (component, sensor,...).

Returns

void

Defined in

2d/src/core/FCollider.ts:217


frame()

frame(_delta): void

Parameters

_delta: number

Returns

void

Defined in

2d/src/core/FCollider.ts:140

Properties

__COLLIDER__

__COLLIDER__: Collider

RAPIER Collider

Defined in

2d/src/core/FCollider.ts:31


__COMPONENT__?

optional __COMPONENT__: FComponent

The component the collider is attached to.

Defined in

2d/src/core/FCollider.ts:35


offset

offset: FTransform

The transform offset of the collider.

Defined in

2d/src/core/FCollider.ts:43


shape

shape: FShapes

The shape of the collider.

Defined in

2d/src/core/FCollider.ts:47


transform

transform: FTransform

The transform of the collider.

Defined in

2d/src/core/FCollider.ts:39