Skip to content

@fibbojs / core / FCamera

Class: abstract FCamera

The base class for cameras in Fibbo.

Extends

Constructors

new FCamera()

new FCamera(): FCamera

Returns

FCamera

Overrides

FComponent.constructor

Defined in

core/src/FCamera.ts:8

Methods

emitCollisionWith()

emitCollisionWith(options): void

Emit a collision event with a given class or object.

Parameters

options

The options for the collision event.

options.class?: any

The class to emit the collision event with.

options.component?: FComponent

The component to emit the collision event with.

Returns

void

Examples

typescript
const player = new Player()
const enemy = new Enemy()
player.emitCollisionWith({
  class: Enemy
})
typescript
const player = new Player()
const enemy = new Enemy()
player.emitCollisionWith({
  object: enemy
})

Inherited from

FComponent.emitCollisionWith

Defined in

core/src/FComponent.ts:135


onCollisionWith()

onCollisionWith(classOrObject, callback): () => void

Add a callback to be called when a collision occurs.

Parameters

classOrObject: any

The class or object to add the callback to.

callback

The callback to add.

Returns

Function

A function to remove the callback.

Returns

void

Examples

typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(Enemy, () => {
  console.log('Player collided with an Enemy!')
})
typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(enemy, () => {
  console.log('Player collided with the enemy!')
})

Inherited from

FComponent.onCollisionWith

Defined in

core/src/FComponent.ts:85


onFrame()

onFrame(delta): void

Update the component. Should be called every frame. The purpose of onFrame on FComponent is really to render the component, its mesh/sprite and its properties. Any changes on its transform should be done on the controller, not here.

Parameters

delta: number

The time since the last frame.

Returns

void

Inherited from

FComponent.onFrame

Defined in

core/src/FComponent.ts:56


setZoom()

abstract setZoom(zoom): void

Set the zoom of the camera.

Parameters

zoom: number

Returns

void

Defined in

core/src/FCamera.ts:15

Properties

__CALLBACKS_ON_COLLISION__

__CALLBACKS_ON_COLLISION__: object = {}

Callbacks for when a collision occurs with a given class or object. It is a dictionary where the key is the class name or object id and the value is an array of callbacks.

Index Signature

[key: string]: (data) => void[]

Inherited from

FComponent.__CALLBACKS_ON_COLLISION__

Defined in

core/src/FComponent.ts:39


__ID__

__ID__: number

Unique identifier for the component. It is generated automatically.

Inherited from

FComponent.__ID__

Defined in

core/src/FComponent.ts:33


__IS_2D__

__IS_2D__: boolean = false

Inherited from

FComponent.__IS_2D__

Defined in

core/src/FComponent.ts:27


__IS_3D__

__IS_3D__: boolean = false

Internal flags

Inherited from

FComponent.__IS_3D__

Defined in

core/src/FComponent.ts:26


controller?

optional controller: FController

The controller attached to the component.

Inherited from

FComponent.controller

Defined in

core/src/FComponent.ts:44