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 |
Members
-
<static> canBePooled :Boolean
-
Entity base class is not poolable.
Type:
- Boolean
-
<static> nextId :Number
-
ID of next Entity instance
Type:
-
<static> types :Object
-
Entity class map.
Type:
- Object
-
behaviorList :Array
-
Behavior list
Type:
- Array
-
behaviors :Object
-
Behavior hash map
Type:
- Object
-
canEverTick :boolean
-
Want this actor to be updated?
Type:
- boolean
-
canFixedTick :boolean
-
Want this actor to be fixed-updated?
Type:
- boolean
-
CTOR :class
-
Reference to the constructor for pooling.
Type:
- class
-
events :EventEmitter
-
Events dispatcher
Type:
-
game :Game
-
Reference to the game this actor is added to.
Type:
-
isRemoved :boolean
-
Whether this actor is removed from game.
Type:
- boolean
-
name :string
-
Name of this Entity, default is null.
Type:
- string
-
tag :string
-
Set tag of this Entity
Type:
- string
-
tag :string
-
Get tag of this Entity
Type:
- string
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
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 callsuper.update
if you don't have any behaviors.Parameters:
Name Type Description dt
Number Delta time in millisecond
dtSec
Number Delta time in second
-
ready()
-
Will be called after this Entity is added to a game.
-
setup(settings)
-
Setup this entity with settings(deeply merge is used by default)
Parameters:
Name Type Description settings
Object Settings
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 callsuper.update
if you don't have any behaviors.Parameters:
Name Type Description dt
Number Delta time in millisecond
dtSec
Number Delta time in second