|
|
@ -21,11 +21,9 @@ class ChromeDino extends BodyComponent with InitialPosition {
|
|
|
|
/// The size of the dinosour mouth.
|
|
|
|
/// The size of the dinosour mouth.
|
|
|
|
static final size = Vector2(5, 2.5);
|
|
|
|
static final size = Vector2(5, 2.5);
|
|
|
|
|
|
|
|
|
|
|
|
late final _ChromeDinoJoint _joint;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc
|
|
|
|
/// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc
|
|
|
|
/// motion.
|
|
|
|
/// motion.
|
|
|
|
Future<void> _anchorToJoint() async {
|
|
|
|
Future<_ChromeDinoJoint> _anchorToJoint() async {
|
|
|
|
final anchor = _ChromeDinoAnchor(chromeDino: this);
|
|
|
|
final anchor = _ChromeDinoAnchor(chromeDino: this);
|
|
|
|
await add(anchor);
|
|
|
|
await add(anchor);
|
|
|
|
|
|
|
|
|
|
|
@ -33,18 +31,19 @@ class ChromeDino extends BodyComponent with InitialPosition {
|
|
|
|
chromeDino: this,
|
|
|
|
chromeDino: this,
|
|
|
|
anchor: anchor,
|
|
|
|
anchor: anchor,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
_joint = _ChromeDinoJoint(jointDef);
|
|
|
|
final joint = _ChromeDinoJoint(jointDef);
|
|
|
|
world.createJoint2(_joint);
|
|
|
|
world.createJoint2(joint);
|
|
|
|
|
|
|
|
return joint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
await super.onLoad();
|
|
|
|
await super.onLoad();
|
|
|
|
await _anchorToJoint();
|
|
|
|
final joint = await _anchorToJoint();
|
|
|
|
await add(
|
|
|
|
await add(
|
|
|
|
TimerComponent(
|
|
|
|
TimerComponent(
|
|
|
|
period: 1,
|
|
|
|
period: 1,
|
|
|
|
onTick: _joint.swivel,
|
|
|
|
onTick: joint.swivel,
|
|
|
|
repeat: true,
|
|
|
|
repeat: true,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -136,6 +135,7 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef {
|
|
|
|
anchor.body.position,
|
|
|
|
anchor.body.position,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
enableLimit = true;
|
|
|
|
enableLimit = true;
|
|
|
|
|
|
|
|
// TODO(alestiago): Apply design angle value.
|
|
|
|
const angle = math.pi / 3.5;
|
|
|
|
const angle = math.pi / 3.5;
|
|
|
|
lowerAngle = -angle / 2;
|
|
|
|
lowerAngle = -angle / 2;
|
|
|
|
upperAngle = angle / 2;
|
|
|
|
upperAngle = angle / 2;
|
|
|
|