|
|
@ -21,92 +21,39 @@ class BackboardGameOver extends PositionComponent with HasGameRef {
|
|
|
|
required int score,
|
|
|
|
required int score,
|
|
|
|
required String characterIconPath,
|
|
|
|
required String characterIconPath,
|
|
|
|
BackboardOnSubmit? onSubmit,
|
|
|
|
BackboardOnSubmit? onSubmit,
|
|
|
|
}) : _score = score,
|
|
|
|
}) : _onSubmit = onSubmit,
|
|
|
|
_characterIconPath = characterIconPath,
|
|
|
|
super(
|
|
|
|
_onSubmit = onSubmit;
|
|
|
|
children: [
|
|
|
|
|
|
|
|
_BackboardSpriteComponent(),
|
|
|
|
|
|
|
|
_BackboardDisplaySpriteComponent(),
|
|
|
|
|
|
|
|
_ScoreTextComponent(score.formatScore()),
|
|
|
|
|
|
|
|
_CharacterIconSpriteComponent(characterIconPath),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
final int _score;
|
|
|
|
|
|
|
|
final String _characterIconPath;
|
|
|
|
|
|
|
|
final BackboardOnSubmit? _onSubmit;
|
|
|
|
final BackboardOnSubmit? _onSubmit;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
final backgroundSprite = await gameRef.loadSprite(
|
|
|
|
|
|
|
|
Assets.images.backboard.backboardGameOver.keyName,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
unawaited(
|
|
|
|
|
|
|
|
add(
|
|
|
|
|
|
|
|
SpriteComponent(
|
|
|
|
|
|
|
|
sprite: backgroundSprite,
|
|
|
|
|
|
|
|
size: backgroundSprite.originalSize / 10,
|
|
|
|
|
|
|
|
anchor: Anchor.bottomCenter,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final displaySprite = await gameRef.loadSprite(
|
|
|
|
|
|
|
|
Assets.images.backboard.display.keyName,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
unawaited(
|
|
|
|
|
|
|
|
add(
|
|
|
|
|
|
|
|
SpriteComponent(
|
|
|
|
|
|
|
|
sprite: displaySprite,
|
|
|
|
|
|
|
|
size: displaySprite.originalSize / 10,
|
|
|
|
|
|
|
|
anchor: Anchor.bottomCenter,
|
|
|
|
|
|
|
|
position: Vector2(0, -11.5),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unawaited(
|
|
|
|
|
|
|
|
add(
|
|
|
|
|
|
|
|
TextComponent(
|
|
|
|
|
|
|
|
text: _score.formatScore(),
|
|
|
|
|
|
|
|
position: Vector2(-34, -45),
|
|
|
|
|
|
|
|
anchor: Anchor.centerLeft,
|
|
|
|
|
|
|
|
textRenderer: Backboard.textPaint,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final characterIconSprite = await Sprite.load(
|
|
|
|
|
|
|
|
_characterIconPath,
|
|
|
|
|
|
|
|
images: Images(prefix: ''),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
unawaited(
|
|
|
|
|
|
|
|
add(
|
|
|
|
|
|
|
|
SpriteComponent(
|
|
|
|
|
|
|
|
sprite: characterIconSprite,
|
|
|
|
|
|
|
|
size: characterIconSprite.originalSize / 10,
|
|
|
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|
|
|
|
position: Vector2(18.4, -45),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < 3; i++) {
|
|
|
|
for (var i = 0; i < 3; i++) {
|
|
|
|
unawaited(
|
|
|
|
await add(
|
|
|
|
add(
|
|
|
|
BackboardLetterPrompt(
|
|
|
|
BackboardLetterPrompt(
|
|
|
|
position: Vector2(
|
|
|
|
position: Vector2(
|
|
|
|
24.3 + (4.5 * i),
|
|
|
|
24.3 + (4.5 * i),
|
|
|
|
-45,
|
|
|
|
-45,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
hasFocus: i == 0,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
hasFocus: i == 0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unawaited(
|
|
|
|
await add(
|
|
|
|
add(
|
|
|
|
KeyboardInputController(
|
|
|
|
KeyboardInputController(
|
|
|
|
keyUp: {
|
|
|
|
keyUp: {
|
|
|
|
LogicalKeyboardKey.arrowLeft: () => _movePrompt(true),
|
|
|
|
LogicalKeyboardKey.arrowLeft: () => _movePrompt(true),
|
|
|
|
LogicalKeyboardKey.arrowRight: () => _movePrompt(false),
|
|
|
|
LogicalKeyboardKey.arrowRight: () => _movePrompt(false),
|
|
|
|
LogicalKeyboardKey.enter: _submit,
|
|
|
|
LogicalKeyboardKey.enter: _submit,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -135,3 +82,67 @@ class BackboardGameOver extends PositionComponent with HasGameRef {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _BackboardSpriteComponent extends SpriteComponent with HasGameRef {
|
|
|
|
|
|
|
|
_BackboardSpriteComponent() : super(anchor: Anchor.bottomCenter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
|
|
|
await super.onLoad();
|
|
|
|
|
|
|
|
final sprite = await gameRef.loadSprite(
|
|
|
|
|
|
|
|
Assets.images.backboard.backboardGameOver.keyName,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.sprite = sprite;
|
|
|
|
|
|
|
|
size = sprite.originalSize / 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _BackboardDisplaySpriteComponent extends SpriteComponent with HasGameRef {
|
|
|
|
|
|
|
|
_BackboardDisplaySpriteComponent()
|
|
|
|
|
|
|
|
: super(
|
|
|
|
|
|
|
|
anchor: Anchor.bottomCenter,
|
|
|
|
|
|
|
|
position: Vector2(0, -11.5),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
|
|
|
await super.onLoad();
|
|
|
|
|
|
|
|
final sprite = await gameRef.loadSprite(
|
|
|
|
|
|
|
|
Assets.images.backboard.display.keyName,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.sprite = sprite;
|
|
|
|
|
|
|
|
size = sprite.originalSize / 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _ScoreTextComponent extends TextComponent {
|
|
|
|
|
|
|
|
_ScoreTextComponent(String score)
|
|
|
|
|
|
|
|
: super(
|
|
|
|
|
|
|
|
text: score,
|
|
|
|
|
|
|
|
anchor: Anchor.centerLeft,
|
|
|
|
|
|
|
|
position: Vector2(-34, -45),
|
|
|
|
|
|
|
|
textRenderer: Backboard.textPaint,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _CharacterIconSpriteComponent extends SpriteComponent {
|
|
|
|
|
|
|
|
_CharacterIconSpriteComponent(String characterIconPath)
|
|
|
|
|
|
|
|
: _characterIconPath = characterIconPath,
|
|
|
|
|
|
|
|
super(
|
|
|
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|
|
|
|
position: Vector2(18.4, -45),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final String _characterIconPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
|
|
|
await super.onLoad();
|
|
|
|
|
|
|
|
final sprite = await Sprite.load(
|
|
|
|
|
|
|
|
_characterIconPath,
|
|
|
|
|
|
|
|
images: Images(prefix: ''),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.sprite = sprite;
|
|
|
|
|
|
|
|
size = sprite.originalSize / 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|