Class: Entity

Core.Entity

new Core.Entity (game, name, alive, x, y, automated)

Entity object of the game engine.
Name Type Description
game Core.Game the game object
name String the name of the entity
alive Boolean is the entity enabled or disabled?
x Number the x coordinate
y Number the y coordinate
automated Boolean should the entity be automated (in update, render, etc)

Members

auto_physics Boolean

should automate physics

auto_render Boolean

should automate rendering

auto_update Boolean

should automate update

children Object

children dictionary

game Core.Game

the engine instance that created it

name String

name

transform Core.Transform

transform

Methods

addChild (name, child)

adds child to entity
Name Type Description
name String child name
child object child, can be of any type; if present setParent() is called.

addComponent (comp)

adds component to entity
Name Type Description
comp Type type/constructor to add as component.

clearParent ()

clears current parent of entity (set to null)

delChild (childName)Boolean

delete a child by name
Name Type Description
childName String the child name
Returns:
Type Description
Boolean true if succeeded; false otherwise

delComponent (componentName)Boolean

delete component
Name Type Description
componentName String the component name
Returns:
Type Description
Boolean true if succeeded; false otherwise

delComponentOfType (componentType)Boolean

deletes component of type
Name Type Description
componentType Type the component type
Returns:
Type Description
Boolean true if succeeded; false otherwise

destroy ()

prepares entity components for deletion

end_render ()

ends rendering the entity (restores transform to graphical context)

getBuiltinComponent (compName)object

gets built-in component by simplified name.
Name Type Description
compName String built-in component's simplified name (usually type in lowercases)
Returns:
Type Description
object built-in component if found; null otherwise.

getChild (name)object

gets child by name (recursively)
Name Type Description
name String child name to check for
Returns:
Type Description
object the child if found; null otherwise.

getChildAt (i)object

gets child by index
Name Type Description
i Number the child index
Returns:
Type Description
object the child if found; null otherwise.

getChildName ()String

generates child name (serial indexing)
Returns:
Type Description
String generated child name

getComponent (compName)object

gets component from name
Name Type Description
compName String component name to search for.
Returns:
Type Description
object the component if found; null otherwise.

getComponentOfType (type)object

gets component by type
Name Type Description
type Type the component's type (constructor name)
Returns:
Type Description
object the component if found; null otherwise.

getDimentions ()Utils.Vector2d

gets default dimentions (encapsulating children)
Returns:
Type Description
Utils.Vector2d default width height 2d vector.

getEntityChildren ()Array

gets array of entity children
Returns:
Type Description
Array the entity children of this entity

getGlobalTransform ()Utils.Vector2d

gets global (recursive/world) transform.
Returns:
Type Description
Utils.Vector2d the global transform.

hasComponentOfType (type)Boolean

checks whether a component of type is attached
Name Type Description
type Type component type to search for
Returns:
Type Description
Boolean true if component of type is attached; false otherwise.

hasOwnChild (name)Boolean

checks whether entity has child with certain name.
Name Type Description
name String child name to check
Returns:
Type Description
Boolean true if has, false otherwise

insertChild (c)

adds child with generated name
Name Type Description
c object the child object to add.

render ()

renders the entity (and it's children)

setDimentions (w, h)

force dimentions
Name Type Description
w Number width
h Number height

setParent (entity)

sets parent of current entity (make sure it's actually a child!)
Name Type Description
entity Core.Entity parent entity

start_render ()

starts rendering the entity (applies transform to the graphical context)

update ()

updates the entity and it's children