Game Development Reference
In-Depth Information
this.addComponent = addComponent;
this.removeComponent = removeComponent;
this.getComponent = getComponent;
this.getPosition = function() {
return pos;
};
this.setPosition = function(newPos) {
pos = newPos;
};
this.isActive = function() {
return isActive;
};
this.setActive = function(active) {
isActive = active;
};
this.draw = draw;
this.update = update;
this.update = function() {
update();
};
// Save a reference to a new update callback
function
this.setOnUpdate = function(cb){
update = cb;
};
};
As you can see, this entity class is really quite bare bones. It takes into account
what our game needs to do, what is used in the game, and it encapsulates the most
common functionality based on that. From here we can instantiate an entity and add
components to it, making it a very unique entity, based on all that it potentially can
and cannot do.
Search WWH ::




Custom Search