Skip to content

@fibbojs / 2d / FFixedCamera

Class: FFixedCamera ​

A fixed camera.

Extends ​

Constructors ​

new FFixedCamera() ​

new FFixedCamera(options?): FFixedCamera

Parameters ​

• options?: FCameraOptions

Returns ​

FFixedCamera

Overrides ​

FCamera.constructor

Defined in ​

2d/src/cameras/FFixedCamera.ts:9

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/FFixedCamera.ts:13


__SET_POSITION__() ​

__SET_POSITION__(position): void

Parameters ​

• position

• position.x: number

• position.y: number

Returns ​

void

Inherited from ​

FCamera.__SET_POSITION__

Defined in ​

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


__UPDATE_POSITION__() ​

__UPDATE_POSITION__(): void

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

Returns ​

void

Inherited from ​

FCamera.__UPDATE_POSITION__

Defined in ​

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


__UPDATE_ROTATION__() ​

__UPDATE_ROTATION__(): void

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

Returns ​

void

Inherited from ​

FCamera.__UPDATE_ROTATION__

Defined in ​

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


__UPDATE_SCALE__() ​

__UPDATE_SCALE__(): void

Update the scale of the camera according to the transform. This method should be called after updating the transform properties. This method does not make sense for cameras, but it is implemented for consistency.

Returns ​

void

Inherited from ​

FCamera.__UPDATE_SCALE__

Defined in ​

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


addController() ​

addController(controller): void

Add a controller to the component.

Parameters ​

• controller: FController

The controller to add.

Returns ​

void

Inherited from ​

FCamera.addController

Defined in ​

core/dist/index.d.ts:418


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:499


emitOnLoaded() ​

emitOnLoaded(): void

Emit the onLoaded callbacks.

Returns ​

void

Inherited from ​

FCamera.emitOnLoaded

Defined in ​

core/dist/index.d.ts:443


frame() ​

frame(delta): void

Update the component. Should be called every frame. The purpose of this method is to render the component, its mesh/sprite, and its properties.

Parameters ​

• delta: number

The time since the last frame.

Returns ​

void

Inherited from ​

FCamera.frame

Defined in ​

core/dist/index.d.ts:429


onCollisionWith() ​

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

Add a callback to be called when a collision occurs.

Parameters ​

• classOrObject: any

The class or object to observe for collisions. Should inherit from FComponent.

• callback

The callback to add to the collision event.

Returns ​

Function

A function to remove the callback.

Returns ​

void

Examples ​

typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(Enemy, ({ component }) => {
  console.log('Player collided with an Enemy!')
  console.log('The enemy is:', component)
})
typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(enemy, () => {
  console.log('Player collided with the enemy!')
})
typescript
const player = new Player()
const enemy = new Enemy()
const removeThisCallback = player.onCollisionWith(enemy, () => {
 console.log('Player collided with the enemy!')
})
// To remove the callback, call the function returned by onCollisionWith
removeThisCallback()

#### Inherited from

[`FCamera`](FCamera.md).[`onCollisionWith`](FCamera.md#oncollisionwith)

#### Defined in

core/dist/index.d.ts:476

***

### onFrame()

> **onFrame**(`callback`): `void`

Add a callback to be called every frame.

#### Parameters

• **callback**

The callback function.

#### Returns

`void`

#### Inherited from

[`FCamera`](FCamera.md).[`onFrame`](FCamera.md#onframe)

#### Defined in

core/dist/index.d.ts:434

***

### onLoaded()

> **onLoaded**(`callback`): `void`

Add a callback to be called when the component is loaded (could be a texture, a 3D model, etc).

#### Parameters

• **callback**

The callback function.

#### Returns

`void`

#### Inherited from

[`FCamera`](FCamera.md).[`onLoaded`](FCamera.md#onloaded)

#### Defined in

core/dist/index.d.ts:439

***

### removeController()

> **removeController**(`controller`): `void`

Remove a controller from the component.

#### Parameters

• **controller**: `FController`

The controller to remove.

#### Returns

`void`

#### Inherited from

[`FCamera`](FCamera.md).[`removeController`](FCamera.md#removecontroller)

#### Defined in

core/dist/index.d.ts:423

***

### setZoom()

> **setZoom**(`zoom`): `void`

#### Parameters

• **zoom**: `number`

#### Returns

`void`

#### Inherited from

[`FCamera`](FCamera.md).[`setZoom`](FCamera.md#setzoom)

#### Defined in

[2d/src/cameras/FCamera.ts:51](https://github.com/fibbojs/fibbo/blob/65626b456ab47d7e61b23a8dd1be9f399238b0f1/packages/2d/src/cameras/FCamera.ts#L51)

## 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`](FCamera.md).[`__CALLBACKS_ON_COLLISION__`](FCamera.md#__callbacks_on_collision__)

#### Defined in

core/dist/index.d.ts:402

***

### \_\_CALLBACKS\_ON\_FRAME\_\_

> **\_\_CALLBACKS\_ON\_FRAME\_\_**: () => `void`[]

Callbacks for when a frame is rendered.

#### Inherited from

[`FCamera`](FCamera.md).[`__CALLBACKS_ON_FRAME__`](FCamera.md#__callbacks_on_frame__)

#### Defined in

core/dist/index.d.ts:393

***

### \_\_CALLBACKS\_ON\_LOADED\_\_

> **\_\_CALLBACKS\_ON\_LOADED\_\_**: () => `void`[]

Callbacks for when the component is loaded (could be a texture, a 3D model, etc).

#### Inherited from

[`FCamera`](FCamera.md).[`__CALLBACKS_ON_LOADED__`](FCamera.md#__callbacks_on_loaded__)

#### Defined in

core/dist/index.d.ts:397

***

### \_\_ID\_\_

> **\_\_ID\_\_**: `number`

Unique identifier for the component.
It is generated automatically.

#### Inherited from

[`FCamera`](FCamera.md).[`__ID__`](FCamera.md#__id__)

#### Defined in

core/dist/index.d.ts:389

***

### \_\_IS\_2D\_\_

> **\_\_IS\_2D\_\_**: `boolean` = `true`

Internal flags

#### Inherited from

[`FCamera`](FCamera.md).[`__IS_2D__`](FCamera.md#__is_2d__)

#### Defined in

[2d/src/cameras/FCamera.ts:19](https://github.com/fibbojs/fibbo/blob/65626b456ab47d7e61b23a8dd1be9f399238b0f1/packages/2d/src/cameras/FCamera.ts#L19)

***

### \_\_IS\_3D\_\_

> **\_\_IS\_3D\_\_**: `boolean`

Internal flags

#### Inherited from

[`FCamera`](FCamera.md).[`__IS_3D__`](FCamera.md#__is_3d__)

#### Defined in

core/dist/index.d.ts:383

***

### controllers

> **controllers**: `FController`[]

The controllers attached to the component.

#### Inherited from

[`FCamera`](FCamera.md).[`controllers`](FCamera.md#controllers)

#### Defined in

core/dist/index.d.ts:412

***

### scene

> **scene**: [`FScene`](FScene.md)

The scene the component is attached to.

#### Inherited from

[`FCamera`](FCamera.md).[`scene`](FCamera.md#scene)

#### Defined in

[2d/src/cameras/FCamera.ts:21](https://github.com/fibbojs/fibbo/blob/65626b456ab47d7e61b23a8dd1be9f399238b0f1/packages/2d/src/cameras/FCamera.ts#L21)

***

### transform

> **transform**: [`FTransform`](FTransform.md)

Transform of the camera.
It is used to store the position of the camera.
The scale and rotation of the transform are not used.

#### Inherited from

[`FCamera`](FCamera.md).[`transform`](FCamera.md#transform)

#### Defined in

[2d/src/cameras/FCamera.ts:28](https://github.com/fibbojs/fibbo/blob/65626b456ab47d7e61b23a8dd1be9f399238b0f1/packages/2d/src/cameras/FCamera.ts#L28)