refactor: removing baseColor from ball

pull/279/head
RuiAlonso 3 years ago
parent ccf9b33d67
commit f00d31383f

@ -14,7 +14,7 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
with Layered, InitialPosition { with Layered, InitialPosition {
/// {@macro ball} /// {@macro ball}
Ball({ Ball({
required this.baseColor, Color? baseColor,
String? spriteAsset, String? spriteAsset,
}) : super( }) : super(
renderBody: false, renderBody: false,
@ -33,9 +33,6 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
/// The size of the [Ball]. /// The size of the [Ball].
static final Vector2 size = Vector2.all(4.13); static final Vector2 size = Vector2.all(4.13);
/// The base [Color] used to tint this [Ball].
final Color baseColor;
@override @override
Body createBody() { Body createBody() {
final shape = CircleShape()..radius = size.x / 2; final shape = CircleShape()..radius = size.x / 2;

@ -5,7 +5,7 @@ import 'package:sandbox/common/common.dart';
class BallGame extends AssetsGame with TapDetector, Traceable { class BallGame extends AssetsGame with TapDetector, Traceable {
BallGame({ BallGame({
this.color = Colors.blue, Color? color,
this.ballPriority = 0, this.ballPriority = 0,
this.ballLayer = Layer.all, this.ballLayer = Layer.all,
this.character, this.character,
@ -34,7 +34,6 @@ class BallGame extends AssetsGame with TapDetector, Traceable {
'Dino': Assets.images.ball.dinoBall.keyName, 'Dino': Assets.images.ball.dinoBall.keyName,
}; };
final Color color;
final int ballPriority; final int ballPriority;
final Layer ballLayer; final Layer ballLayer;
final String? character; final String? character;
@ -43,7 +42,6 @@ class BallGame extends AssetsGame with TapDetector, Traceable {
void onTapUp(TapUpInfo info) { void onTapUp(TapUpInfo info) {
add( add(
Ball( Ball(
baseColor: color,
spriteAsset: characterBallPaths[character], spriteAsset: characterBallPaths[character],
) )
..initialPosition = info.eventPosition.game ..initialPosition = info.eventPosition.game

@ -1,5 +1,4 @@
import 'package:dashbook/dashbook.dart'; import 'package:dashbook/dashbook.dart';
import 'package:flutter/material.dart';
import 'package:sandbox/common/common.dart'; import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/ball/ball_booster_game.dart'; import 'package:sandbox/stories/ball/ball_booster_game.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart'; import 'package:sandbox/stories/ball/basic_ball_game.dart';
@ -7,10 +6,9 @@ import 'package:sandbox/stories/ball/basic_ball_game.dart';
void addBallStories(Dashbook dashbook) { void addBallStories(Dashbook dashbook) {
dashbook.storiesOf('Ball') dashbook.storiesOf('Ball')
..addGame( ..addGame(
title: 'Colored', title: 'Themed',
description: BallGame.description, description: BallGame.description,
gameBuilder: (context) => BallGame( gameBuilder: (context) => BallGame(
color: context.colorProperty('color', Colors.blue),
character: context.listProperty( character: context.listProperty(
'Character', 'Character',
BallGame.characterBallPaths.keys.first, BallGame.characterBallPaths.keys.first,

Loading…
Cancel
Save