|
|
@ -29,9 +29,8 @@ class ChromeDino extends BodyComponent with InitialPosition {
|
|
|
|
chromeDino: this,
|
|
|
|
chromeDino: this,
|
|
|
|
anchor: anchor,
|
|
|
|
anchor: anchor,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
final joint = world.createJoint(jointDef) as RevoluteJoint;
|
|
|
|
final joint = _ChromeDinoJoint(jointDef)..create(world);
|
|
|
|
|
|
|
|
joint.swivel(joint, removed);
|
|
|
|
_ChromeDinoAnchorRevoluteJointDef.swivel(joint, removed);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(alestiago): Remove once the following is added to Flame.
|
|
|
|
// TODO(alestiago): Remove once the following is added to Flame.
|
|
|
@ -143,11 +142,20 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef {
|
|
|
|
maxMotorTorque = 999;
|
|
|
|
maxMotorTorque = 999;
|
|
|
|
motorSpeed = 999;
|
|
|
|
motorSpeed = 999;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _ChromeDinoJoint extends RevoluteJoint {
|
|
|
|
|
|
|
|
_ChromeDinoJoint(_ChromeDinoAnchorRevoluteJointDef def) : super(def);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(alestiago): Remove once Forge2D supports custom joints.
|
|
|
|
|
|
|
|
void create(World world) {
|
|
|
|
|
|
|
|
world.joints.add(this);
|
|
|
|
|
|
|
|
bodyA.joints.add(this);
|
|
|
|
|
|
|
|
bodyB.joints.add(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Sweeps the [ChromeDino] up and down repeatedly.
|
|
|
|
/// Sweeps the [ChromeDino] up and down repeatedly.
|
|
|
|
// TODO(alestiago): consider refactor once the issue is solved:
|
|
|
|
void swivel(RevoluteJoint joint, Completer completer) {
|
|
|
|
// https://github.com/flame-engine/forge2d/issues/36
|
|
|
|
|
|
|
|
static void swivel(RevoluteJoint joint, Completer completer) {
|
|
|
|
|
|
|
|
Future.doWhile(() async {
|
|
|
|
Future.doWhile(() async {
|
|
|
|
if (completer.isCompleted) return false;
|
|
|
|
if (completer.isCompleted) return false;
|
|
|
|
|
|
|
|
|
|
|
|