Skip to content

@fibbojs / 2d / FFreeCamera

Class: FFreeCamera

A free camera that can be moved around.

Extends

Constructors

new FFreeCamera()

new FFreeCamera(scene, options?): FFreeCamera

Parameters

scene: FScene

options?: FCameraOptions

Returns

FFreeCamera

Overrides

FCamera.constructor

Defined in

2d/src/cameras/FFreeCamera.ts:10

Methods

__ON_CAMERA_ADDED_TO_SCENE_PLEASE_DO_NOT_CALL_THIS_BY_HAND__()

__ON_CAMERA_ADDED_TO_SCENE_PLEASE_DO_NOT_CALL_THIS_BY_HAND__(): void

Returns

void

Overrides

FCamera.__ON_CAMERA_ADDED_TO_SCENE_PLEASE_DO_NOT_CALL_THIS_BY_HAND__

Defined in

2d/src/cameras/FFreeCamera.ts:17


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

FCamera.emitCollisionWith

Defined in

core/dist/index.d.ts:116


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

FCamera.onCollisionWith

Defined in

core/dist/index.d.ts:93


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

Returns

void

Overrides

FCamera.onFrame

Defined in

2d/src/cameras/FFreeCamera.ts:14


setZoom()

setZoom(zoom): void

Set the zoom of the camera.

Parameters

zoom: number

Returns

void

Inherited from

FCamera.setZoom

Defined in

2d/src/cameras/FCamera.ts:57

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

FCamera.__CALLBACKS_ON_COLLISION__

Defined in

core/dist/index.d.ts:56


__ID__

__ID__: number

Unique identifier for the component. It is generated automatically.

Inherited from

FCamera.__ID__

Defined in

core/dist/index.d.ts:51


__IS_2D__

__IS_2D__: boolean = true

Internal flags

Inherited from

FCamera.__IS_2D__

Defined in

2d/src/cameras/FCamera.ts:16


__IS_3D__

__IS_3D__: boolean

Internal flags

Inherited from

FCamera.__IS_3D__

Defined in

core/dist/index.d.ts:45


controller?

optional controller: FController

The controller attached to the component.

Inherited from

FCamera.controller

Defined in

core/dist/index.d.ts:62


position

position: object

Position of the camera.

x

x: number

y

y: number

Inherited from

FCamera.position

Defined in

2d/src/cameras/FCamera.ts:27


scene

scene: FScene

The scene the camera is in.

Inherited from

FCamera.scene

Defined in

2d/src/cameras/FCamera.ts:21