Actor extends Emitter#
cruft/core/Actor.js
This class defines an Actor.
Importing#
import Actor from "cruft/core/Actor";
Constructors#
Actor( [ guid ] )#
guid - guid of actor.
let actor = new Actor();
//or
let actor2 = new Actor(12); //actor2.guid === 12;
Properties#
.guid - guid of the actor.
.parent - Strong reference to parent actor.
.components - Object containing strong references to the actor's components.
.children - Object containing strong references to the actor's children.
.initialized - Whether the actor has been initialized.
Methods#
addComponent( component )#
Add a component to an actor.
actor.addComponent(component);
getComponent( type )#
Get a component of the specified type.
let transform = actor.getComponent("transform");
removeComponent( type )#
Remove a component of the specified type.
actor.removeComponent("transform");
addChild( child )#
Add a child to an actor.
let actor1 = new Actor();
let actor2 = new Actor();
actor1.addChild(actor2);
removeChild( child )#
Remove a child from an actor.
actor1.removeChild(actor2)
setParent( parent )#
Method used to set actor's parent reference.
AddChild already takes care of setting a child's parent.
actor1.setParent(actor2);
update( now , deltaMs )#
Recursive function to update all children Actor/Component 's of an actor.
actor.update(now, deltaMs);
destroy( )#
DESC
//example