Skip to content

@fibbojs / 2d / FLight

Class: abstract FLight

The base class for 2d lights in Fibbo.

Extends

  • FLight

Accessors

color

get color(): number

set color(color): void

Parameters

color: number

Returns

number

Defined in

2d/src/lights/FLight.ts:88


intensity

get intensity(): number

set intensity(intensity): void

Parameters

intensity: number

Returns

number

Defined in

2d/src/lights/FLight.ts:96


lookAt

get lookAt(): object

set lookAt(lookAt): void

Parameters

lookAt

lookAt.x: number

lookAt.y: number

Returns

object

x

x: number

y

y: number

Defined in

2d/src/lights/FLight.ts:100

Constructors

new FLight()

new FLight(scene, options?): FLight

Parameters

scene: FScene

options?: FLightOptions

Returns

FLight

Overrides

FLightCore.constructor

Defined in

2d/src/lights/FLight.ts:45

Methods

applyTransform()

applyTransform(): void

Returns

void

Defined in

2d/src/lights/FLight.ts:75


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

FLightCore.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

FLightCore.onCollisionWith

Defined in

core/dist/index.d.ts:93


onFrame()

abstract 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

FLightCore.onFrame

Defined in

2d/src/lights/FLight.ts:73

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]: () => void[]

Overrides

FLightCore.__CALLBACKS_ON_COLLISION__

Defined in

2d/src/lights/FLight.ts:23


__ID__

__ID__: number

Unique identifier for the component. It is generated automatically.

Overrides

FLightCore.__ID__

Defined in

2d/src/lights/FLight.ts:22


__IS_2D__

__IS_2D__: boolean = false

Overrides

FLightCore.__IS_2D__

Defined in

2d/src/lights/FLight.ts:21


__IS_3D__

__IS_3D__: boolean = true

Internal flags

Overrides

FLightCore.__IS_3D__

Defined in

2d/src/lights/FLight.ts:20


__LOOK_AT__

__LOOK_AT__: object

Look at target of the light.

x

x: number

y

y: number

Defined in

2d/src/lights/FLight.ts:43


controller?

optional controller: FController

The controller attached to the component.

Inherited from

FLightCore.controller

Defined in

core/dist/index.d.ts:62


light

light: any

The original light object from PIXI.js.

Defined in

2d/src/lights/FLight.ts:28


scene

scene: FScene

Scene the light is in.

Defined in

2d/src/lights/FLight.ts:33


transform

transform: FTransform

Transform of the light.

Defined in

2d/src/lights/FLight.ts:38