Forwards physics body properties to box2d in sprite physics

This commit is contained in:
Viktor Lidholt 2015-10-06 10:39:26 -07:00
parent 5ac4d1ea28
commit b6e12ca9aa

View File

@ -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 {
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 {
_body.angularDamping = angularDampening; _body.angularDamping = angularDampening;
} }
bool allowSleep; bool _allowSleep;
bool awake; bool get allowSleep => _allowSleep;
bool fixedRotation; set allowSleep(bool allowSleep) {
_allowSleep = allowSleep;
bool bullet; if (_body != null)
_body.setSleepingAllowed(allowSleep);
}
bool active; bool _awake;
bool get awake {
if (_body != null)
return _body.isAwake();
else
return _awake;
}
set awake(bool awake) {
_awake = awake;
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;