Commit b6e12ca9 authored by Viktor Lidholt's avatar Viktor Lidholt

Forwards physics body properties to box2d in sprite physics

parent 5ac4d1ea
...@@ -17,11 +17,11 @@ class PhysicsBody { ...@@ -17,11 +17,11 @@ class PhysicsBody {
double angularVelocity: 0.0, double angularVelocity: 0.0,
this.linearDampening: 0.0, this.linearDampening: 0.0,
double awakeangularDampening: 0.0, double awakeangularDampening: 0.0,
this.allowSleep: true, bool allowSleep: true,
this.awake: true, bool awake: true,
this.fixedRotation: false, bool fixedRotation: false,
this.bullet: false, bool bullet: false,
this.active: true, bool active: true,
this.gravityScale: 1.0 this.gravityScale: 1.0
}) { }) {
this.density = density; this.density = density;
...@@ -32,6 +32,12 @@ class PhysicsBody { ...@@ -32,6 +32,12 @@ class PhysicsBody {
this.linearVelocity = linearVelocity; this.linearVelocity = linearVelocity;
this.angularVelocity = angularVelocity; this.angularVelocity = angularVelocity;
this.angularDampening = angularDampening; this.angularDampening = angularDampening;
this.allowSleep = allowSleep;
this.awake = awake;
this.fixedRotation = fixedRotation;
this.bullet = bullet;
this.active = active;
} }
Object tag; Object tag;
...@@ -151,15 +157,71 @@ class PhysicsBody { ...@@ -151,15 +157,71 @@ class PhysicsBody {
_body.angularDamping = angularDampening; _body.angularDamping = angularDampening;
} }
bool allowSleep; bool _allowSleep;
bool get allowSleep => _allowSleep;
set allowSleep(bool allowSleep) {
_allowSleep = allowSleep;
bool awake; if (_body != null)
_body.setSleepingAllowed(allowSleep);
}
bool fixedRotation; bool _awake;
bool get awake {
if (_body != null)
return _body.isAwake();
else
return _awake;
}
bool bullet; set awake(bool awake) {
_awake = awake;
bool active; if (_body != null)
_body.setAwake(awake);
}
bool _fixedRotation;
bool get fixedRotation => _fixedRotation;
set fixedRotation(bool fixedRotation) {
_fixedRotation = fixedRotation;
if (_body != null)
_body.setFixedRotation(fixedRotation);
}
bool _bullet;
bool get bullet => _bullet;
set bullet(bool bullet) {
_bullet = bullet;
if (_body != null) {
_body.setBullet(bullet);
}
}
bool _active;
bool get active {
if (_body != null)
return _body.isActive();
else
return _active;
}
set active(bool active) {
_active = active;
if (_body != null)
_body.setActive(active);
}
double gravityScale; double gravityScale;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment