CameraEntity
Defined in: renderer/src/CameraEntity.ts:57
Camera entity. Spawn in a scene to enable camera-based layer transforms.
const cam = this.spawn(CameraEntity, { follow: player.get(Transform), smoothing: 0.15, bounds: { minX: 0, minY: 0, maxX: 2000, maxY: 2000 },});
// All camera operations are available directly on the entity:cam.shake(8, 300);cam.zoomTo(1.5, 1000);cam.follow(otherTarget, { smoothing: 0.1 });Extends
Section titled “Extends”Entity
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CameraEntity(
name?,tags?):CameraEntity
Defined in: core/dist/index.d.ts:351
Parameters
Section titled “Parameters”string
Iterable<string, any, any>
Returns
Section titled “Returns”CameraEntity
Inherited from
Section titled “Inherited from”Entity.constructor
Properties
Section titled “Properties”
readonlyid:number
Defined in: core/dist/index.d.ts:339
Unique auto-incrementing ID.
Inherited from
Section titled “Inherited from”Entity.id
readonlyname:string
Defined in: core/dist/index.d.ts:341
Display name for debugging.
Inherited from
Section titled “Inherited from”Entity.name
readonlytags:Set<string>
Defined in: core/dist/index.d.ts:343
Tags for group queries.
Inherited from
Section titled “Inherited from”Entity.tags
[TRAITS_KEY]
Section titled “[TRAITS_KEY]”
static[TRAITS_KEY]:Set<symbol>
Defined in: core/dist/index.d.ts:337
Inherited from
Section titled “Inherited from”Entity.[TRAITS_KEY]
Accessors
Section titled “Accessors”bounds
Section titled “bounds”Get Signature
Section titled “Get Signature”get bounds():
CameraBounds|undefined
Defined in: renderer/src/CameraEntity.ts:115
Returns
Section titled “Returns”CameraBounds | undefined
Set Signature
Section titled “Set Signature”set bounds(
value):void
Defined in: renderer/src/CameraEntity.ts:119
Parameters
Section titled “Parameters”CameraBounds | undefined
Returns
Section titled “Returns”void
children
Section titled “children”Get Signature
Section titled “Get Signature”get children():
ReadonlyMap<string,Entity>
Defined in: core/dist/index.d.ts:371
Named children as a read-only map. Empty map if no children.
Returns
Section titled “Returns”ReadonlyMap<string, Entity>
Inherited from
Section titled “Inherited from”Entity.children
effectivePosition
Section titled “effectivePosition”Get Signature
Section titled “Get Signature”get effectivePosition():
Vec2
Defined in: renderer/src/CameraEntity.ts:123
Returns
Section titled “Returns”Vec2
isDestroyed
Section titled “isDestroyed”Get Signature
Section titled “Get Signature”get isDestroyed():
boolean
Defined in: core/dist/index.d.ts:367
True if destroy() has been called.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Entity.isDestroyed
parent
Section titled “parent”Get Signature
Section titled “Get Signature”get parent():
Entity|null
Defined in: core/dist/index.d.ts:369
The parent entity, or null if this is a root entity.
Returns
Section titled “Returns”Entity | null
Inherited from
Section titled “Inherited from”Entity.parent
position
Section titled “position”Get Signature
Section titled “Get Signature”get position():
Vec2
Defined in: renderer/src/CameraEntity.ts:91
Returns
Section titled “Returns”Vec2
Set Signature
Section titled “Set Signature”set position(
value):void
Defined in: renderer/src/CameraEntity.ts:95
Parameters
Section titled “Parameters”Vec2
Returns
Section titled “Returns”void
rotation
Section titled “rotation”Get Signature
Section titled “Get Signature”get rotation():
number
Defined in: renderer/src/CameraEntity.ts:107
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set rotation(
value):void
Defined in: renderer/src/CameraEntity.ts:111
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Get Signature
Section titled “Get Signature”get scene():
Scene
Defined in: core/dist/index.d.ts:363
The scene this entity belongs to. Throws if the entity is not attached
to a scene — which in practice only happens before scene.spawn /
addChild wires it up, or after destroy() tears it down. Inside
lifecycle methods (setup, component onAdd, update, etc.) this is
always safe to access.
For the rare case where you genuinely need to inspect whether an
entity has a scene (e.g. defensive code in systems iterating a query
result), use tryScene instead.
Returns
Section titled “Returns”Scene
Inherited from
Section titled “Inherited from”Entity.scene
tryScene
Section titled “tryScene”Get Signature
Section titled “Get Signature”get tryScene():
Scene|null
Defined in: core/dist/index.d.ts:365
The scene this entity belongs to, or null if detached.
Returns
Section titled “Returns”Scene | null
Inherited from
Section titled “Inherited from”Entity.tryScene
Get Signature
Section titled “Get Signature”get zoom():
number
Defined in: renderer/src/CameraEntity.ts:99
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set zoom(
value):void
Defined in: renderer/src/CameraEntity.ts:103
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Methods
Section titled “Methods”_performDestroy()
Section titled “_performDestroy()”_performDestroy():
void
Defined in: core/dist/index.d.ts:426
Internal
Internal: perform actual destruction — remove all components and clear state. Called by Scene during endOfFrame flush.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity._performDestroy
_setScene()
Section titled “_setScene()”_setScene(
scene,callbacks):void
Defined in: core/dist/index.d.ts:443
Internal
Internal: set the scene and callbacks. Called by Scene.spawn().
Parameters
Section titled “Parameters”Scene | null
callbacks
Section titled “callbacks”EntityCallbacks | null
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity._setScene
add<
C>(component):C
Defined in: core/dist/index.d.ts:403
Add a component instance. Returns the component for chaining.
Type Parameters
Section titled “Type Parameters”C extends Component
Parameters
Section titled “Parameters”component
Section titled “component”C
Returns
Section titled “Returns”C
Inherited from
Section titled “Inherited from”Entity.add
addChild()
Section titled “addChild()”addChild(
name,child):void
Defined in: core/dist/index.d.ts:373
Add a named child entity. Auto-adds to parent’s scene if not already in one.
Parameters
Section titled “Parameters”string
Entity
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity.addChild
afterRestore()?
Section titled “afterRestore()?”
optionalafterRestore(data,resolve):void
Defined in: core/dist/index.d.ts:436
Called after components are restored during save/load. Rebuild non-serializable state here.
Parameters
Section titled “Parameters”unknown
resolve
Section titled “resolve”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity.afterRestore
destroy()
Section titled “destroy()”destroy():
void
Defined in: core/dist/index.d.ts:420
Mark for deferred destruction. Actual cleanup happens at end of frame.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity.destroy
emit()
Section titled “emit()”Call Signature
Section titled “Call Signature”emit(
token):void
Defined in: core/dist/index.d.ts:415
Emit a typed event on this entity. Bubbles to the scene.
Parameters
Section titled “Parameters”EventToken<void>
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity.emit
Call Signature
Section titled “Call Signature”emit<
T>(token,data):void
Defined in: core/dist/index.d.ts:416
Emit a typed event on this entity. Bubbles to the scene.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”EventToken<T>
T
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity.emit
follow()
Section titled “follow()”follow(
target,options?):void
Defined in: renderer/src/CameraEntity.ts:131
Parameters
Section titled “Parameters”target
Section titled “target”position
Section titled “position”Vec2Like
options?
Section titled “options?”Returns
Section titled “Returns”void
get<
C>(cls):C
Defined in: core/dist/index.d.ts:405
Get a component by class. Throws if not found.
Type Parameters
Section titled “Type Parameters”C extends Component
Parameters
Section titled “Parameters”ComponentClass<C>
Returns
Section titled “Returns”C
Inherited from
Section titled “Inherited from”Entity.get
getAll()
Section titled “getAll()”getAll():
Iterable<Component>
Defined in: core/dist/index.d.ts:418
Get all components as an iterable.
Returns
Section titled “Returns”Iterable<Component>
Inherited from
Section titled “Inherited from”Entity.getAll
getChild()
Section titled “getChild()”getChild(
name):Entity
Defined in: core/dist/index.d.ts:399
Get a child by name. Throws if not found.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Entity
Inherited from
Section titled “Inherited from”Entity.getChild
has(
cls):boolean
Defined in: core/dist/index.d.ts:409
Check if entity has a component of the given class.
Parameters
Section titled “Parameters”ComponentClass
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Entity.has
hasTrait()
Section titled “hasTrait()”hasTrait<
T>(token):this is CameraEntity & T
Defined in: core/dist/index.d.ts:438
Check if this entity’s class implements a given trait. Acts as a type guard.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”TraitToken<T>
Returns
Section titled “Returns”this is CameraEntity & T
Inherited from
Section titled “Inherited from”Entity.hasTrait
on<
T>(token,handler): () =>void
Defined in: core/dist/index.d.ts:413
Subscribe to a typed event on this entity. Returns an unsubscribe function.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”EventToken<T>
handler
Section titled “handler”(data) => void
Returns
Section titled “Returns”() => void
Inherited from
Section titled “Inherited from”Entity.on
remove()
Section titled “remove()”remove(
cls):void
Defined in: core/dist/index.d.ts:411
Remove a component by class.
Parameters
Section titled “Parameters”ComponentClass
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Entity.remove
removeChild()
Section titled “removeChild()”removeChild(
name):Entity
Defined in: core/dist/index.d.ts:397
Remove a named child. Returns the detached entity.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Entity
Inherited from
Section titled “Inherited from”Entity.removeChild
screenToWorld()
Section titled “screenToWorld()”screenToWorld(
screenX,screenY):Vec2
Defined in: renderer/src/CameraEntity.ts:151
Parameters
Section titled “Parameters”screenX
Section titled “screenX”number
screenY
Section titled “screenY”number
Returns
Section titled “Returns”Vec2
serialize()?
Section titled “serialize()?”
optionalserialize():unknown
Defined in: core/dist/index.d.ts:434
Return a JSON-serializable snapshot of this entity’s custom state. Used by the save system.
Returns
Section titled “Returns”unknown
Inherited from
Section titled “Inherited from”Entity.serialize
setup()
Section titled “setup()”setup(
params?):void
Defined in: renderer/src/CameraEntity.ts:60
Optional setup method. Called by scene.spawn(Class, params) after the
entity is wired to its scene, so components can access services.
Override in subclasses — do NOT use the constructor for component setup.
Parameters
Section titled “Parameters”params?
Section titled “params?”CameraEntityParams = {}
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”Entity.setup
shake()
Section titled “shake()”shake(
intensity,duration,options?):void
Defined in: renderer/src/CameraEntity.ts:139
Parameters
Section titled “Parameters”intensity
Section titled “intensity”number
duration
Section titled “duration”number
options?
Section titled “options?”Returns
Section titled “Returns”void
spawnChild()
Section titled “spawnChild()”Call Signature
Section titled “Call Signature”spawnChild(
name):Entity
Defined in: core/dist/index.d.ts:389
Spawn a new entity in this entity’s scene and add it as a named child.
Combines scene.spawn(...) + this.addChild(name, ...) in one call —
the idiomatic way to compose entity trees (logical root + visual body
- UI sibling + …).
Mirrors the overload shape of Scene.spawn: pass an Entity subclass
(with optional setup params), a Blueprint, or omit for an anonymous
base Entity.
this.spawnChild("body", EnemyBody, { color: 0xff6b6b });this.spawnChild("hp", EnemyHealthBar);Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Entity
Inherited from
Section titled “Inherited from”Entity.spawnChild
Call Signature
Section titled “Call Signature”spawnChild<
E>(name,Class):E
Defined in: core/dist/index.d.ts:390
Spawn a new entity in this entity’s scene and add it as a named child.
Combines scene.spawn(...) + this.addChild(name, ...) in one call —
the idiomatic way to compose entity trees (logical root + visual body
- UI sibling + …).
Mirrors the overload shape of Scene.spawn: pass an Entity subclass
(with optional setup params), a Blueprint, or omit for an anonymous
base Entity.
this.spawnChild("body", EnemyBody, { color: 0xff6b6b });this.spawnChild("hp", EnemyHealthBar);Type Parameters
Section titled “Type Parameters”E extends Entity
Parameters
Section titled “Parameters”string
() => E
Returns
Section titled “Returns”E
Inherited from
Section titled “Inherited from”Entity.spawnChild
Call Signature
Section titled “Call Signature”spawnChild<
E,P>(name,Class,params):E
Defined in: core/dist/index.d.ts:391
Spawn a new entity in this entity’s scene and add it as a named child.
Combines scene.spawn(...) + this.addChild(name, ...) in one call —
the idiomatic way to compose entity trees (logical root + visual body
- UI sibling + …).
Mirrors the overload shape of Scene.spawn: pass an Entity subclass
(with optional setup params), a Blueprint, or omit for an anonymous
base Entity.
this.spawnChild("body", EnemyBody, { color: 0xff6b6b });this.spawnChild("hp", EnemyHealthBar);Type Parameters
Section titled “Type Parameters”E extends Entity
P
Parameters
Section titled “Parameters”string
() => E & object
params
Section titled “params”P
Returns
Section titled “Returns”E
Inherited from
Section titled “Inherited from”Entity.spawnChild
Call Signature
Section titled “Call Signature”spawnChild<
P>(name,blueprint,params):Entity
Defined in: core/dist/index.d.ts:394
Spawn a new entity in this entity’s scene and add it as a named child.
Combines scene.spawn(...) + this.addChild(name, ...) in one call —
the idiomatic way to compose entity trees (logical root + visual body
- UI sibling + …).
Mirrors the overload shape of Scene.spawn: pass an Entity subclass
(with optional setup params), a Blueprint, or omit for an anonymous
base Entity.
this.spawnChild("body", EnemyBody, { color: 0xff6b6b });this.spawnChild("hp", EnemyHealthBar);Type Parameters
Section titled “Type Parameters”P
Parameters
Section titled “Parameters”string
blueprint
Section titled “blueprint”Blueprint<P>
params
Section titled “params”P
Returns
Section titled “Returns”Entity
Inherited from
Section titled “Inherited from”Entity.spawnChild
Call Signature
Section titled “Call Signature”spawnChild(
name,blueprint):Entity
Defined in: core/dist/index.d.ts:395
Spawn a new entity in this entity’s scene and add it as a named child.
Combines scene.spawn(...) + this.addChild(name, ...) in one call —
the idiomatic way to compose entity trees (logical root + visual body
- UI sibling + …).
Mirrors the overload shape of Scene.spawn: pass an Entity subclass
(with optional setup params), a Blueprint, or omit for an anonymous
base Entity.
this.spawnChild("body", EnemyBody, { color: 0xff6b6b });this.spawnChild("hp", EnemyHealthBar);Parameters
Section titled “Parameters”string
blueprint
Section titled “blueprint”Blueprint<void>
Returns
Section titled “Returns”Entity
Inherited from
Section titled “Inherited from”Entity.spawnChild
tryGet()
Section titled “tryGet()”tryGet<
C>(cls):C|undefined
Defined in: core/dist/index.d.ts:407
Get a component by class, or undefined if not found.
Type Parameters
Section titled “Type Parameters”C extends Component
Parameters
Section titled “Parameters”ComponentClass<C>
Returns
Section titled “Returns”C | undefined
Inherited from
Section titled “Inherited from”Entity.tryGet
tryGetChild()
Section titled “tryGetChild()”tryGetChild(
name):Entity|undefined
Defined in: core/dist/index.d.ts:401
Get a child by name, or undefined if not found.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Entity | undefined
Inherited from
Section titled “Inherited from”Entity.tryGetChild
unfollow()
Section titled “unfollow()”unfollow():
void
Defined in: renderer/src/CameraEntity.ts:135
Returns
Section titled “Returns”void
worldToScreen()
Section titled “worldToScreen()”worldToScreen(
worldX,worldY):Vec2
Defined in: renderer/src/CameraEntity.ts:155
Parameters
Section titled “Parameters”worldX
Section titled “worldX”number
worldY
Section titled “worldY”number
Returns
Section titled “Returns”Vec2
zoomTo()
Section titled “zoomTo()”zoomTo(
target,duration,easing?):void
Defined in: renderer/src/CameraEntity.ts:147
Parameters
Section titled “Parameters”target
Section titled “target”number
duration
Section titled “duration”number
easing?
Section titled “easing?”EasingFunction
Returns
Section titled “Returns”void