TileMap
Hierarchy
- Entity
- TileMap
Index
Constructors
Properties
Accessors
Methods
- _initialize
- addChild
- addComponent
- addTag
- addTemplate
- clearComponents
- clone
- debug
- draw
- emit
- flagCollidersDirty
- flagTilesDirty
- get
- getAncestors
- getColumns
- getComponents
- getDescendants
- getOnScreenTiles
- getRows
- getTile
- getTileByIndex
- getTileByPoint
- has
- hasAll
- hasAllTags
- hasTag
- isKilled
- kill
- off
- on
- onInitialize
- onPostUpdate
- onPreUpdate
- once
- removeAllChildren
- removeChild
- removeComponent
- removeTag
- unparent
- update
Constructors
constructor
Parameters
options: TileMapOptions
Returns TileMap
Properties
publicactive
Whether this entity is active, if set to false it will be reclaimed
publicchildrenAdded$
publicchildrenRemoved$
publiccollider
publicreadonlycolumns
publiccomponentAdded$
publiccomponentRemoved$
publicreadonlycomponents
Current components on the entity
Do not modify
Use addComponent/removeComponent otherwise the ECS will not be notified of changes.
publicevents
Listen to or emit events for an entity
publicid
The unique identifier for the entity
publiclogger
publicmeshingLookBehind
publicname
publicrenderFromTopOfGraphic
publicreadonlyrows
publicscene
The current scene that the entity is in, if any
publictagAdded$
publictagRemoved$
publicreadonlytileHeight
publicreadonlytileWidth
publicreadonlytiles
publictransform
Accessors
publicchildren
Get the direct children of this entity
Returns readonly Entity<any>[]
publicisInitialized
Gets whether the actor is Initialized
Returns boolean
publicparent
Returns Entity<any>
publicpos
publicrotation
Returns number
Parameters
val: number
Returns void
publicscale
publictags
Specifically get the tags on the entity from [[TagsComponent]]
Returns Set<string>
publictypes
The types of the components on the Entity
Returns ComponentCtor[]
publicvel
publicx
Returns number
Parameters
val: number
Returns void
publicy
Returns number
Parameters
val: number
Returns void
publicz
Returns number
Parameters
val: number
Returns void
Methods
public_initialize
Parameters
engine: Engine<any>
Returns void
publicaddChild
publicaddComponent
publicaddTag
Adds a tag to an entity
Parameters
tag: string
Returns void
publicaddTemplate
publicclearComponents
Returns void
publicclone
Creates a deep copy of the entity and a copy of all its components
Returns Entity<any>
publicdebug
Parameters
gfx: ExcaliburGraphicsContext
debugFlags: DebugConfig
Returns void
publicdraw
Draws the tile map to the screen. Called by the [[Scene]].
Parameters
ctx: ExcaliburGraphicsContext
ExcaliburGraphicsContext
delta: number
The number of milliseconds since the last draw
Returns void
publicemit
Type parameters
- TEventName: EventKey<TileMapEvents>
Parameters
eventName: TEventName
event: TileMapEvents[TEventName]
Returns void
publicflagCollidersDirty
Returns void
publicflagTilesDirty
Returns void
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>[]
publicgetColumns
Returns readonly Tile[][]
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>[]
publicgetOnScreenTiles
Returns the on screen tiles for a tilemap, this will overshoot by a small amount because of the internal quad tree data structure.
Useful if you need to perform specific logic on onscreen tiles
Returns readonly Tile[]
publicgetRows
Returns readonly Tile[][]
publicgetTile
Returns the [[Tile]] by its x and y integer coordinates
For example, if I want the tile in fifth column (x), and second row (y):
getTile(4, 1)
0 based, so 0 is the first in row/columnParameters
x: number
y: number
Returns Tile
publicgetTileByIndex
Returns the [[Tile]] by index (row major order)
Parameters
index: number
Returns Tile
publicgetTileByPoint
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<TileMapEvents>
Parameters
eventName: TEventName
handler: Handler<TileMapEvents[TEventName]>
Returns void
publicon
Type parameters
- TEventName: EventKey<TileMapEvents>
Parameters
eventName: TEventName
handler: Handler<TileMapEvents[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<TileMapEvents>
Parameters
eventName: TEventName
handler: Handler<TileMapEvents[TEventName]>
Returns Subscription
publicremoveAllChildren
Removes all children from this entity
Returns Entity<any>
publicremoveChild
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>>
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
publicupdate
Parameters
engine: Engine<any>
delta: number
Returns void
The TileMap provides a mechanism for doing flat 2D tiles rendered in a grid.
TileMaps are useful for top down or side scrolling grid oriented games.