reduce update packets sent
This commit is contained in:
parent
d6daed2e9b
commit
ef2d067b38
15 changed files with 67 additions and 14 deletions
|
@ -41,6 +41,8 @@ class Body {
|
|||
type: 'body',
|
||||
fixtures: this.mounts.length
|
||||
};
|
||||
|
||||
this.sleepTime = 0;
|
||||
}
|
||||
|
||||
destruct() {
|
||||
|
@ -88,6 +90,8 @@ class Body {
|
|||
if(pos.y < bounds.top) this.applyForce(0, 0.03);
|
||||
if(pos.y > bounds.bottom) this.applyForce(-0, -0.03);
|
||||
|
||||
this.sleepTime++;
|
||||
|
||||
this.tickType();
|
||||
}
|
||||
|
||||
|
@ -135,6 +139,15 @@ class Body {
|
|||
return {};
|
||||
}
|
||||
|
||||
get awake() {
|
||||
if (this.b2body.IsAwake()) {
|
||||
this.sleepTime = 0;
|
||||
return true;
|
||||
} else {
|
||||
return this.sleepTime < 50;
|
||||
}
|
||||
}
|
||||
|
||||
get com() {
|
||||
return {
|
||||
x: this.b2body.GetLocalCenter().x,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue