You can add components to entities by using the add method:
- entity.add(new PositionComponent());
+ entity.addComponent(new PositionComponent());
Systems can refer to entities by requesting nodes.
*
* returns true if added, false if already present
*/
- add : function add(component) {
+ addComponent : function addComponent(component) {
if (this._componentKeys.indexOf(component.constructor) >= 0) {
return false;
}
* components can be any class whatsoever.
*/
Class(Serpentity, "Component")({
+ prototype : {
+ init : function init(config) {
+ var property;
+ config = config || {};
+
+ for (property in config) {
+ if (config.hasOwnProperty(property)) {
+ this[property] = config[property];
+ }
+ }
+ }
+ }
});
/*