diff --git a/lib/game/components/flipper.dart b/lib/game/components/flipper.dart index 0cbbb525..a68257f5 100644 --- a/lib/game/components/flipper.dart +++ b/lib/game/components/flipper.dart @@ -123,15 +123,6 @@ class Flipper extends PositionBodyComponent with KeyboardHandler { body.linearVelocity = Vector2(0, _speed); } - @override - Future onLoad() async { - await super.onLoad(); - await Future.wait([ - _loadSprite(), - _anchorToJoint(), - ]); - } - /// Loads the sprite that renders with the [Flipper]. Future _loadSprite() async { final sprite = await gameRef.loadSprite(spritePath); @@ -167,19 +158,6 @@ class Flipper extends PositionBodyComponent with KeyboardHandler { ); } - @override - Body createBody() { - final bodyDef = BodyDef() - ..gravityScale = 0 - ..type = BodyType.dynamic - ..position = _position; - - final body = world.createBody(bodyDef); - _createFixtureDefs().forEach(body.createFixture); - - return body; - } - List _createFixtureDefs() { final fixtures = []; final isLeft = side.isLeft; @@ -226,6 +204,28 @@ class Flipper extends PositionBodyComponent with KeyboardHandler { return fixtures; } + @override + Future onLoad() async { + await super.onLoad(); + await Future.wait([ + _loadSprite(), + _anchorToJoint(), + ]); + } + + @override + Body createBody() { + final bodyDef = BodyDef() + ..gravityScale = 0 + ..type = BodyType.dynamic + ..position = _position; + + final body = world.createBody(bodyDef); + _createFixtureDefs().forEach(body.createFixture); + + return body; + } + @override bool onKeyEvent( RawKeyEvent event,