|
|
@ -1,10 +1,18 @@
|
|
|
|
import 'package:flame/input.dart';
|
|
|
|
import 'package:flame/input.dart';
|
|
|
|
|
|
|
|
import 'package:flame_bloc/flame_bloc.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
import 'package:sandbox/common/common.dart';
|
|
|
|
import 'package:sandbox/common/common.dart';
|
|
|
|
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
|
|
|
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class PlungerGame extends BallGame
|
|
|
|
class PlungerGame extends BallGame
|
|
|
|
with HasKeyboardHandlerComponents, Traceable {
|
|
|
|
with HasKeyboardHandlerComponents, Traceable {
|
|
|
|
|
|
|
|
PlungerGame()
|
|
|
|
|
|
|
|
: super(
|
|
|
|
|
|
|
|
imagesFileNames: [
|
|
|
|
|
|
|
|
Assets.images.plunger.plunger.keyName,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
static const description = '''
|
|
|
|
static const description = '''
|
|
|
|
Shows how Plunger is rendered.
|
|
|
|
Shows how Plunger is rendered.
|
|
|
|
|
|
|
|
|
|
|
@ -19,7 +27,12 @@ class PlungerGame extends BallGame
|
|
|
|
final center = screenToWorld(camera.viewport.canvasSize! / 2);
|
|
|
|
final center = screenToWorld(camera.viewport.canvasSize! / 2);
|
|
|
|
final plunger = Plunger()
|
|
|
|
final plunger = Plunger()
|
|
|
|
..initialPosition = Vector2(center.x - 8.8, center.y);
|
|
|
|
..initialPosition = Vector2(center.x - 8.8, center.y);
|
|
|
|
await add(plunger);
|
|
|
|
await add(
|
|
|
|
|
|
|
|
FlameBlocProvider<PlungerCubit, PlungerState>(
|
|
|
|
|
|
|
|
create: PlungerCubit.new,
|
|
|
|
|
|
|
|
children: [plunger],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
await plunger.add(PlungerKeyControllingBehavior());
|
|
|
|
await plunger.add(PlungerKeyControllingBehavior());
|
|
|
|
|
|
|
|
|
|
|
|
await traceAllBodies();
|
|
|
|
await traceAllBodies();
|
|
|
|