Tile
Hierarchy
- Entity
- Tile
Index
Constructors
Properties
Accessors
Methods
- addChild
- addCollider
- addComponent
- addGraphic
- addTag
- addTemplate
- clearColliders
- clearComponents
- clearGraphics
- clone
- emit
- flagDirty
- get
- getAncestors
- getColliders
- getComponents
- getDescendants
- getGraphics
- getGraphicsOffsets
- has
- hasAll
- hasAllTags
- hasTag
- isKilled
- kill
- off
- on
- onInitialize
- onPostUpdate
- onPreUpdate
- once
- removeAllChildren
- removeChild
- removeCollider
- removeComponent
- removeGraphic
- removeTag
- unparent
Constructors
constructor
Parameters
options: TileOptions
Returns Tile
Properties
publicactive
Whether this entity is active, if set to false it will be reclaimed
publicchildrenAdded$
publicchildrenRemoved$
publiccomponentAdded$
publiccomponentRemoved$
publicreadonlycomponents
Current components on the entity
Do not modify
Use addComponent/removeComponent otherwise the ECS will not be notified of changes.
publicdata
Arbitrary data storage per tile, useful for any game specific data
publicevents
Listen to or emit events for an entity
publicid
The unique identifier for the entity
publicmap
Reference to the TileMap this tile is associated with
publicname
publicscene
The current scene that the entity is in, if any
publictagAdded$
publictagRemoved$
publicreadonlyx
Integer x coordinate of the tile
publicreadonlyy
Integer y coordinate of the tile
Accessors
publicbounds
Tile bounds in world space
Returns BoundingBox
publiccenter
Tile position in world space
Returns Vector
publicchildren
Get the direct children of this entity
Returns readonly Entity<any>[]
publicdefaultGeometry
Returns BoundingBox
publicheight
Height of the tile in pixels
Returns number
publicisInitialized
Gets whether the actor is Initialized
Returns boolean
publicparent
Returns Entity<any>
publicpos
Return the world position of the top left corner of the tile
Returns Vector
publicsolid
Wether this tile should be treated as solid by the tilemap
Returns boolean
Wether this tile should be treated as solid by the tilemap
Parameters
val: boolean
Returns void
publictags
Specifically get the tags on the entity from [[TagsComponent]]
Returns Set<string>
publictypes
The types of the components on the Entity
Returns ComponentCtor[]
publicwidth
Width of the tile in pixels
Returns number
Methods
publicaddChild
publicaddCollider
Adds a custom collider to the [[Tile]] to use instead of it's bounds
If no collider is set but [[Tile.solid]] is set, the tile bounds are used as a collider.
Note! the [[Tile.solid]] must be set to true for it to act as a "fixed" collider
Parameters
collider: Collider
Returns void
publicaddComponent
publicaddGraphic
publicaddTag
Adds a tag to an entity
Parameters
tag: string
Returns void
publicaddTemplate
publicclearColliders
Clears all colliders from the [[Tile]]
Returns void
publicclearComponents
Returns void
publicclearGraphics
Clear all graphics from this tile
Returns void
publicclone
Creates a deep copy of the entity and a copy of all its components
Returns Entity<any>
publicemit
Type parameters
- TEventName: EventKey<EntityEvents>
Parameters
eventName: TEventName
event: EntityEvents[TEventName]
Returns void
publicflagDirty
Returns boolean
get
Type parameters
- TComponent: Component
Parameters
type: ComponentCtor<TComponent>
Returns MaybeKnownComponent<TComponent, any>
publicgetAncestors
Returns a list of parent entities starting with the topmost parent. Includes the current entity.
Returns Entity<any>[]
publicgetColliders
Returns the list of colliders
Returns readonly Collider[]
publicgetComponents
Returns all component instances on entity
Returns Component[]
publicgetDescendants
Returns a list of all the entities that descend from this entity. Includes the current entity.
Returns Entity<any>[]
publicgetGraphics
Current list of graphics for this tile
Returns readonly Graphic[]
publicgetGraphicsOffsets
Current list of offsets for this tile's graphics
Returns readonly Vector[]
publichas
Check if a component type exists
Type parameters
- TComponent: Component
Parameters
type: ComponentCtor<TComponent>
Returns boolean
hasAll
Verifies that an entity has all the required types
Type parameters
- TComponent: Component
Parameters
requiredTypes: ComponentCtor<TComponent>[]
Returns boolean
hasAllTags
Verifies that an entity has all the required tags
Parameters
requiredTags: string[]
Returns boolean
publichasTag
Check if a tag exists on the entity
Parameters
tag: string
name to check for
Returns boolean
publicisKilled
Returns boolean
publickill
Kill the entity, means it will no longer be updated. Kills are deferred to the end of the update. If parented it will be removed from the parent when killed.
Returns void
publicoff
Type parameters
- TEventName: EventKey<EntityEvents>
Parameters
eventName: TEventName
handler: Handler<EntityEvents[TEventName]>
Returns void
publicon
Type parameters
- TEventName: EventKey<EntityEvents>
Parameters
eventName: TEventName
handler: Handler<EntityEvents[TEventName]>
Returns Subscription
publiconInitialize
onInitialize
is called before the first update of the entity. This method is meant to be overridden.Synonymous with the event handler
.on('initialize', (evt) => {...})
Parameters
engine: Engine<any>
Returns void
publiconPostUpdate
Safe to override onPostUpdate lifecycle event handler. Synonymous with
.on('postupdate', (evt) =>{...})
onPostUpdate
is called directly after an entity is updated.Parameters
engine: Engine<any>
delta: number
Returns void
publiconPreUpdate
Safe to override onPreUpdate lifecycle event handler. Synonymous with
.on('preupdate', (evt) =>{...})
onPreUpdate
is called directly before an entity is updated.Parameters
engine: Engine<any>
delta: number
Returns void
publiconce
Type parameters
- TEventName: EventKey<EntityEvents>
Parameters
eventName: TEventName
handler: Handler<EntityEvents[TEventName]>
Returns Subscription
publicremoveAllChildren
Removes all children from this entity
Returns Entity<any>
publicremoveChild
publicremoveCollider
Removes a collider from the [[Tile]]
Parameters
collider: Collider
Returns void
publicremoveComponent
Removes a component from the entity, by default removals are deferred to the end of entity update to avoid consistency issues
Components can be force removed with the
force
flag, the removal is not deferred and happens immediatelyType parameters
- TComponent: Component
Parameters
typeOrInstance: TComponent | ComponentCtor<TComponent>
force: boolean = false
Returns Entity<Exclude<any, TComponent>>
publicremoveGraphic
Remove an instance of a [[Graphic]] from this tile
Parameters
graphic: Graphic
Returns void
publicremoveTag
Removes a tag on the entity
Removals are deferred until the end of update
Parameters
tag: string
Returns void
publicunparent
Unparents this entity, if there is a parent. Otherwise it does nothing.
Returns void
TileMap Tile
A light-weight object that occupies a space in a collision map. Generally created by a [[TileMap]].
Tiles can draw multiple sprites. Note that the order of drawing is the order of the sprites in the array so the last one will be drawn on top. You can use transparency to create layers this way.