mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
new system for synchronizing game objects. fixes #74
This commit is contained in:
parent
3ef3a6abf9
commit
07dad646cf
19 changed files with 194 additions and 162 deletions
|
|
@ -1,9 +1,39 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/GameObject"
|
||||
"Game/Core/GameObjects/GameObject",
|
||||
"Lib/Vendor/Box2D"
|
||||
],
|
||||
|
||||
function(Parent) {
|
||||
function (Parent, Box2D) {
|
||||
|
||||
return Parent;
|
||||
"use strict";
|
||||
|
||||
function GameObject(physicsEngine, uid) {
|
||||
Parent.call(this, physicsEngine, uid);
|
||||
}
|
||||
|
||||
GameObject.prototype = Object.create(Parent.prototype);
|
||||
|
||||
GameObject.prototype.getUpdateData = function(getSleeping) {
|
||||
|
||||
if (!this.body) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.body.GetType() === Box2D.Dynamics.b2Body.b2_staticBody) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!getSleeping && !this.body.IsAwake()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
p: this.body.GetPosition(),
|
||||
a: this.body.GetAngle(),
|
||||
lv: this.body.GetLinearVelocity(),
|
||||
av: this.body.GetAngularVelocity()
|
||||
};
|
||||
}
|
||||
|
||||
return GameObject;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue