mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
first attempt to implement GameObject
This commit is contained in:
parent
aa30a23ca1
commit
fe0d4a66e2
14 changed files with 328 additions and 129 deletions
29
app/Game/Core/GameObjects/GameObject.js
Normal file
29
app/Game/Core/GameObjects/GameObject.js
Normal 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;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue