first attempt to implement GameObject

This commit is contained in:
Jeena 2013-12-19 15:16:15 +01:00
parent aa30a23ca1
commit fe0d4a66e2
14 changed files with 328 additions and 129 deletions

View file

@ -0,0 +1,29 @@
define([
"Lib/Vendor/Box2D",
"Lib/Utilities/Exception"
],
function (Box2D, Exception) {
function GameObject(physicsEngine) {
var def = this.getBodyDef();
this.body = physicsEngine.getWorld().CreateBody(def);
}
GameObject.prototype.getBodyDef = function() {
throw new Exception('Abstract method GameObject.getBodyDef not overwritten');
};
GameObject.prototype.destroy = function() {
if(this.body instanceof Box2D.Dynamics.b2Body) {
this.body.GetWorld().DestroyBody(this.body);
}
};
GameObject.prototype.getBody = function() {
return this.body;
};
return GameObject;
});