chore: fix nits and add todo

pull/229/head
Allison Ryan 3 years ago
parent 2cd6c0645f
commit 1143f3d89c

@ -12,20 +12,19 @@ import 'package:pinball_components/pinball_components.dart';
/// {@endtemplate} /// {@endtemplate}
class ChromeDino extends BodyComponent with InitialPosition { class ChromeDino extends BodyComponent with InitialPosition {
/// {@macro chrome_dino} /// {@macro chrome_dino}
ChromeDino() : super(priority: RenderPriority.dino) { ChromeDino()
renderBody = false; : super(
} priority: RenderPriority.dino,
renderBody: false,
);
/// The size of the dinosaur mouth. /// The size of the dinosaur mouth.
static final size = Vector2(5.5, 5); static final size = Vector2(5.5, 5);
static const _framesInAnimation = 98;
static const _animationFPS = 1 / 24;
/// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc /// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc
/// motion. /// motion.
Future<_ChromeDinoJoint> _anchorToJoint() async { Future<_ChromeDinoJoint> _anchorToJoint() async {
// TODO(allisonryan0002): try moving to anchor after new body is defined.
final anchor = _ChromeDinoAnchor() final anchor = _ChromeDinoAnchor()
..initialPosition = initialPosition + Vector2(9, -4); ..initialPosition = initialPosition + Vector2(9, -4);
@ -45,9 +44,11 @@ class ChromeDino extends BodyComponent with InitialPosition {
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
final joint = await _anchorToJoint(); final joint = await _anchorToJoint();
const framesInAnimation = 98;
const animationFPS = 1 / 24;
await add( await add(
TimerComponent( TimerComponent(
period: (_framesInAnimation / 2) * _animationFPS, period: (framesInAnimation / 2) * animationFPS,
onTick: joint._swivel, onTick: joint._swivel,
repeat: true, repeat: true,
), ),

Loading…
Cancel
Save