ActorFactory
cruft/core/ActorFactory.js
This class defines an ActorFactory.
Importing#
import ActorFactory from "cruft/core/ActorFactory";
Constructors#
ActorFactory( )#
let factory = new ActorFactory();
Methods#
register( name, creator )#
name - name to associate with the given creator function.
creator - a function that returns an actor.
let EmptyCreator = () => {
return new Actor();
}
factory.register("Empty", EmptyCreator)
create( name, config )#
creates an actor of the given type.
let MyCreator = (config) => {
return new Actor(config.guid);
}
factory.register("MyCreator", MyCreator)
let actor = factory.create("MyCreator", {guid : 12});