@ -55,7 +55,6 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
) ;
) ;
final joint = _FlipperJoint ( jointDef ) ;
final joint = _FlipperJoint ( jointDef ) ;
world . createJoint ( joint ) ;
world . createJoint ( joint ) ;
unawaited ( mounted . whenComplete ( joint . unlock ) ) ;
}
}
List < FixtureDef > _createFixtureDefs ( ) {
List < FixtureDef > _createFixtureDefs ( ) {
@ -132,6 +131,15 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
return body ;
return body ;
}
}
@ override
void onMount ( ) {
super . onMount ( ) ;
gameRef . ready ( ) . whenComplete (
( ) = > body . joints . whereType < _FlipperJoint > ( ) . first . unlock ( ) ,
) ;
}
}
}
class _FlipperSpriteComponent extends SpriteComponent with HasGameRef {
class _FlipperSpriteComponent extends SpriteComponent with HasGameRef {
@ -215,11 +223,8 @@ class _FlipperJoint extends RevoluteJoint {
/ / / The joint is locked when initialized in order to force the [ Flipper ]
/ / / The joint is locked when initialized in order to force the [ Flipper ]
/ / / at its resting position .
/ / / at its resting position .
void lock ( ) {
void lock ( ) {
const angle = _halfSweepingAngle ;
final angle = _halfSweepingAngle * side . direction ;
setLimits (
setLimits ( angle , angle ) ;
angle * side . direction ,
angle * side . direction ,
) ;
}
}
/ / / Unlocks the [ Flipper ] from its resting position .
/ / / Unlocks the [ Flipper ] from its resting position .