Class: Entity

Entity


new Entity(x, y, settings)

Parameters:
Name Type Description
x Number

X coordinate

y Number

Y coordinate

settings Object

Setting object to be merged in

Source:

Members


<static> canBePooled :Boolean

Entity base class is not poolable.

Type:
  • Boolean
Source:

<static> nextId :Number

ID of next Entity instance

Type:
Source:

<static> types :Object

Entity class map.

Type:
  • Object
Source:

behaviorList :Array

Behavior list

Type:
  • Array
Source:

behaviors :Object

Behavior hash map

Type:
  • Object
Source:

canEverTick :boolean

Want this actor to be updated?

Type:
  • boolean
Default Value:
  • false
Source:

canFixedTick :boolean

Want this actor to be fixed-updated?

Type:
  • boolean
Default Value:
  • false
Source:

CTOR :class

Reference to the constructor for pooling.

Type:
  • class
Source:

events :EventEmitter

Events dispatcher

Type:
Source:

game :Game

Reference to the game this actor is added to.

Type:
Default Value:
  • null
Source:

isRemoved :boolean

Whether this actor is removed from game.

Type:
  • boolean
Source:

name :string

Name of this Entity, default is null.

Type:
  • string
Source:

tag :string

Set tag of this Entity

Type:
  • string
Source:

tag :string

Get tag of this Entity

Type:
  • string
Source:

Methods


behave(behavior [, settings])

Add a behavior to this entity.

Parameters:
Name Type Argument Description
behavior Object

Behavior to be added

settings Object <optional>

Settings passed to this behavior

Source:
Returns:

Self for chaining

Type
Entity

fixedUpdate(dt, dtSec)

Update method to be called each fixed step. Set canFixedTick = true to activate.
This method will only update behaviors by default,
no need to call super.update if you don't have any behaviors.

Parameters:
Name Type Description
dt Number

Delta time in millisecond

dtSec Number

Delta time in second

Source:

ready()

Will be called after this Entity is added to a game.

Source:

setup(settings)

Setup this entity with settings(deeply merge is used by default)

Parameters:
Name Type Description
settings Object

Settings

Source:
Returns:

Self for chaining

Type
Entity

update(dt, dtSec)

Update method to be called each frame. Set canEverTick = true to activate.
This method will only update behaviors by default,
no need to call super.update if you don't have any behaviors.

Parameters:
Name Type Description
dt Number

Delta time in millisecond

dtSec Number

Delta time in second

Source:

Class: Entity

Entity


new Entity()

Base object that may contain a graphic element(as gfx)
and a collider instance(as coll).

The gfx and coll share the same postion.

Source:

Members


<static> canBePooled :Boolean

Entity base class is not poolable.

Type:
  • Boolean
Source:

<static> nextId :Number

ID of next Entity instance

Type:
Source:

<static> types :Object

Entity class map.

Type:
  • Object
Source:

behaviorList :Array

Behavior list

Type:
  • Array
Source:

behaviors :Object

Behavior hash map

Type:
  • Object
Source:

canEverTick :boolean

Want this actor to be updated?

Type:
  • boolean
Default Value:
  • false
Source:

canFixedTick :boolean

Want this actor to be fixed-updated?

Type:
  • boolean
Default Value:
  • false
Source:

CTOR :class

Reference to the constructor for pooling.

Type:
  • class
Source:

events :EventEmitter

Events dispatcher

Type:
Source:

game :Game

Reference to the game this actor is added to.

Type:
Default Value:
  • null
Source:

isRemoved :boolean

Whether this actor is removed from game.

Type:
  • boolean
Source:

name :string

Name of this Entity, default is null.

Type:
  • string
Source:

tag :string

Set tag of this Entity

Type:
  • string
Source:

tag :string

Get tag of this Entity

Type:
  • string
Source:

Methods


behave(behavior [, settings])

Add a behavior to this entity.

Parameters:
Name Type Argument Description
behavior Object

Behavior to be added

settings Object <optional>

Settings passed to this behavior

Source:
Returns:

Self for chaining

Type
Entity

fixedUpdate(dt, dtSec)

Update method to be called each fixed step. Set canFixedTick = true to activate.
This method will only update behaviors by default,
no need to call super.update if you don't have any behaviors.

Parameters:
Name Type Description
dt Number

Delta time in millisecond

dtSec Number

Delta time in second

Source:

ready()

Will be called after this Entity is added to a game.

Source:

setup(settings)

Setup this entity with settings(deeply merge is used by default)

Parameters:
Name Type Description
settings Object

Settings

Source:
Returns:

Self for chaining

Type
Entity

update(dt, dtSec)

Update method to be called each frame. Set canEverTick = true to activate.
This method will only update behaviors by default,
no need to call super.update if you don't have any behaviors.

Parameters:
Name Type Description
dt Number

Delta time in millisecond

dtSec Number

Delta time in second

Source: