Entity
The base Entity class provides a wrapper around a PIXI.Container or other PIXI.DisplayObject. It implements a scene graph structure by allowing attachments (child entities) and providing common transformation methods like position, scale, rotation, and alpha.
Entity
Properties
| Property | Type | Default | Description |
|---|---|---|---|
node | PIXI.Container \| PIXI.DisplayObject | PIXI.Container | The underlying PIXI display object. |
attachments | Entity[] | [] | Array of child entities attached to this entity. |
parent | Entity \| null | null | The parent entity that this entity is attached to. |
isVisible | boolean | true | Whether the entity is marked as visible. |
shouldCull | boolean | false | Whether to cull (hide) the entity when outside the camera viewport. |
Methods
isInViewport()
function isInViewport(): booleanReturns whether the entity's bounding box intersects with the current camera viewport.
update()
function update(dt: number, user: object): voidUpdates the entity. Applies view culling if shouldCull is true, and calls update on all attachments.
Getters and Setters
getNode()
function getNode(): PIXI.Container | PIXI.DisplayObjectReturns the underlying PIXI node.
setNode()
function setNode(node: PIXI.Container | PIXI.DisplayObject): voidSets the underlying PIXI node.
getParent()
function getParent(): Entity | nullReturns the parent entity.
setParent()
function setParent(parent: Entity | null): voidSets the parent entity.
getAttachments()
function getAttachments(): Entity[]Returns the array of attached child entities.
addAttachment()
function addAttachment(attachment: Entity, zIndex?: number): voidAdds a child entity and its PIXI node. Optionally sets a zHack property for z-index sorting.
removeAttachment()
function removeAttachment(attachment: Entity): voidRemoves a child entity and its PIXI node.
getRotation()
function getRotation(): numberReturns the rotation of the entity in degrees.
setRotation()
function setRotation(degrees: number): voidSets the rotation of the entity in degrees.
getAlpha()
function getAlpha(): numberReturns the alpha transparency of the entity.
setAlpha()
function setAlpha(alpha: number): voidSets the alpha transparency of the entity.
getScale()
function getScale(): PIXI.ObservablePointReturns the scale of the entity.
setScale()
function setScale(scale: number): voidSets the x and y scale of the entity uniformly.
getScaleX()
function getScaleX(): numberGets the x-axis scale of the entity.
setScaleX()
function setScaleX(scale: number): voidSets the x-axis scale of the entity.
getScaleY()
function getScaleY(): numberGets the y-axis scale of the entity.
setScaleY()
function setScaleY(scale: number): voidSets the y-axis scale of the entity.
getFilters()
function getFilters(): PIXI.Filter[] | nullGets the PIXI filters applied to the entity.
setFilters()
function setFilters(filters: PIXI.Filter[] | null): voidSets the PIXI filters applied to the entity.
getPosition()
function getPosition(): PIXI.Point | PIXI.ObservablePointReturns the position of the entity.
setPosition()
function setPosition(x: number, y: number): voidSets the position of the entity.
getPositionX()
function getPositionX(): numberGets the x-axis position of the entity.
setPositionX()
function setPositionX(x: number): voidSets the x-axis position of the entity.
getPositionY()
function getPositionY(): numberGets the y-axis position of the entity.
setPositionY()
function setPositionY(y: number): voidSets the y-axis position of the entity.
getPivotPoint()
function getPivotPoint(): PIXI.Point | PIXI.ObservablePointGets the pivot point of the entity.
setPivotPoint()
function setPivotPoint(x: number, y: number): voidSets the pivot point of the entity.
getVisible()
function getVisible(): booleanGets whether the entity is visible.
setVisible()
function setVisible(visible: boolean): voidSets whether the entity is visible. Updates the underlying PIXI node's visibility.
getShouldCull()
function getShouldCull(): booleanGets whether the entity should be culled based on the viewport.
setShouldCull()
function setShouldCull(shouldCull: boolean): voidSets whether the entity should be culled based on the viewport.