refactor: modified ball assets for sandbox

pull/279/head
RuiAlonso 3 years ago
parent 0fbb4b4fc5
commit ccf9b33d67

@ -24,6 +24,14 @@ abstract class AssetsGame extends Forge2DGame {
}
abstract class LineGame extends AssetsGame with PanDetector {
LineGame({
List<String>? imagesFileNames,
}) : super(
imagesFileNames: [
if (imagesFileNames != null) ...imagesFileNames,
],
);
Vector2? _lineEnd;
@override

@ -4,6 +4,18 @@ import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/common/common.dart';
class BallBoosterGame extends LineGame {
BallBoosterGame()
: super(
imagesFileNames: [
Assets.images.ball.ball.keyName,
Assets.images.ball.androidBall.keyName,
Assets.images.ball.dashBall.keyName,
Assets.images.ball.dinoBall.keyName,
Assets.images.ball.sparkyBall.keyName,
Assets.images.ball.flameEffect.keyName,
],
);
static const description = '''
Shows how a Ball with a boost works.

@ -8,10 +8,15 @@ class BallGame extends AssetsGame with TapDetector, Traceable {
this.color = Colors.blue,
this.ballPriority = 0,
this.ballLayer = Layer.all,
this.character,
List<String>? imagesFileNames,
}) : super(
imagesFileNames: [
Assets.images.ball.ball.keyName,
Assets.images.ball.androidBall.keyName,
Assets.images.ball.dashBall.keyName,
Assets.images.ball.dinoBall.keyName,
Assets.images.ball.sparkyBall.keyName,
if (imagesFileNames != null) ...imagesFileNames,
],
);
@ -22,14 +27,25 @@ class BallGame extends AssetsGame with TapDetector, Traceable {
- Tap anywhere on the screen to spawn a ball into the game.
''';
static final characterBallPaths = <String, String>{
'Dash': Assets.images.ball.dashBall.keyName,
'Sparky': Assets.images.ball.sparkyBall.keyName,
'Android': Assets.images.ball.androidBall.keyName,
'Dino': Assets.images.ball.dinoBall.keyName,
};
final Color color;
final int ballPriority;
final Layer ballLayer;
final String? character;
@override
void onTapUp(TapUpInfo info) {
add(
Ball(baseColor: color)
Ball(
baseColor: color,
spriteAsset: characterBallPaths[character],
)
..initialPosition = info.eventPosition.game
..layer = ballLayer
..priority = ballPriority,

@ -11,6 +11,11 @@ void addBallStories(Dashbook dashbook) {
description: BallGame.description,
gameBuilder: (context) => BallGame(
color: context.colorProperty('color', Colors.blue),
character: context.listProperty(
'Character',
BallGame.characterBallPaths.keys.first,
BallGame.characterBallPaths.keys.toList(),
),
),
)
..addGame(

Loading…
Cancel
Save