|
|
|
@ -123,15 +123,6 @@ class Flipper extends PositionBodyComponent with KeyboardHandler {
|
|
|
|
|
body.linearVelocity = Vector2(0, _speed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
await super.onLoad();
|
|
|
|
|
await Future.wait([
|
|
|
|
|
_loadSprite(),
|
|
|
|
|
_anchorToJoint(),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Loads the sprite that renders with the [Flipper].
|
|
|
|
|
Future<void> _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<FixtureDef> _createFixtureDefs() {
|
|
|
|
|
final fixtures = <FixtureDef>[];
|
|
|
|
|
final isLeft = side.isLeft;
|
|
|
|
@ -226,6 +204,28 @@ class Flipper extends PositionBodyComponent with KeyboardHandler {
|
|
|
|
|
return fixtures;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> 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,
|
|
|
|
|