API Documentation - Herzucco/Puppets.js GitHub Wiki

###Puppets.run()

####Arguments none

####Description Run the system list of Puppets instance.

####Return none

###Puppets.entity()

####Arguments

  • Name : the entity model's name | Mandatory | STRING
  • Data : the data object with the Mandatory key components which is an array | Mandatory | OBJECT

####Description Add to Puppets a new entity model (or overrides previous if it exists).

####Return true or false

###Puppets.component()

####Arguments

  • Name : the component's name | Mandatory | STRING
  • Constructor : the function called when this component is created, has to return an object | Mandatory | FUNCTION
  • Data : a data object | Optionnal | OBJECT

####Description Add to Puppets a new component (or overrides previous if it exists).

####Return true or false

###Puppets.system()

####Arguments

  • Name : the system's name | Mandatory | STRING
  • Constructor : the function called when the system runs, its arguments have to be ordered like the components list | Mandatory | FUNCTION
  • Data : data object which is the system context, must have a components key which is an array (components list) | Mandatory | OBJECT

####Description Add a system to the end of the Puppets's system list if there isn't key "position" in the data object passed in argument.

####Return true or false

###Puppets.collection()

####Arguments

  • Collection List : the new collection list | Mandatory | ARRAY

OR

  • Collection Name : a new collection name | Mandatory | STRING
  • Position : the position in the current Puppets's collection list | Optionnal | NUMBER

####Description Add a totally new collection list to Puppets or simply add a new collection in the current list at the end of this list, or at the mentioned position.

####Return true or false

###Puppets.systemList()

####Arguments

  • System List : the new system list | Mandatory | ARRAY

####Description Defines a totally new system list to Puppets, which defines the run order of its systems.

####Return The new system's order list | ARRAY

###Puppets.load()

####Arguments

  • URL : url to the js file to load | Mandatory | STRING
  • Success Callback: a method called if the file is loaded | Optionnal | FUNCTION
  • Error Callback : a method called if the file isn't loaded | Optionnal | FUNCTION

####Description Add a js file to the DOM to run it. It is used to load modules.

###Puppets.createEntity()

####Arguments

  • Entity Model : the model to observe to create the entity| Mandatory | STRING
  • Constructor : an object with data for the entity's components | Mandatory | OBJECT
  • Collection : the collection of the created entity | Optionnal | STRING

####Description This method instantiates an entity observing a added model in Puppets. The entity will have the components mentioned in the entity model. The constructor is used to custom and override default components values. The default entity collection is "world", if the collection isn't mentioned.

###Puppets.removeEntity()

####Arguments

  • Entity : the entity to destroy| Mandatory | NUMBER

OR

*Entity List : the list of entities to destroy| Mandatory | ARRAY OF NUMBER

####Description Destroy the selected entity/ies.

###Puppets.removeComponent()

####Arguments

  • Entity : the entity which will loose a component| Mandatory | NUMBER
  • Component : the component to remove| Mandatory | STRING

OR

*Entity List : the list of entities whose will loose a component| Mandatory | ARRAY OF NUMBER

  • Component : the component to remove| Mandatory | STRING

####Description Remove a component of the selected entity/ies.

###Puppets.addComponent()

####Arguments

  • Entity : the entity which will get a component| Mandatory | NUMBER
  • Component : the component to add| Mandatory | STRING

OR

*Entity List : the list of entities whose will get a component| Mandatory | ARRAY OF NUMBER

  • Component : the component to add| Mandatory | STRING

####Description Add a component to the selected entity/ies.

###Puppets.getComponents()

####Arguments

  • Entity : the selected entity| Mandatory | NUMBER

OR

*Entity List : the list of selected entities| Mandatory | ARRAY OF NUMBER

####Description Get the components of the selected entity/ies.