|
|
@ -2,11 +2,12 @@ import 'dart:async';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flame/input.dart';
|
|
|
|
import 'package:flame/input.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
import 'package:pinball_flame/pinball_flame.dart';
|
|
|
|
import 'package:pinball_flame/pinball_flame.dart';
|
|
|
|
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
|
|
|
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class SpaceshipRampGame extends BasicBallGame {
|
|
|
|
class SpaceshipRampGame extends BasicBallGame with KeyboardEvents {
|
|
|
|
SpaceshipRampGame()
|
|
|
|
SpaceshipRampGame()
|
|
|
|
: super(
|
|
|
|
: super(
|
|
|
|
color: Colors.blue,
|
|
|
|
color: Colors.blue,
|
|
|
@ -19,13 +20,45 @@ class SpaceshipRampGame extends BasicBallGame {
|
|
|
|
|
|
|
|
|
|
|
|
- Activate the "trace" parameter to overlay the body.
|
|
|
|
- Activate the "trace" parameter to overlay the body.
|
|
|
|
- Tap anywhere on the screen to spawn a ball into the game.
|
|
|
|
- Tap anywhere on the screen to spawn a ball into the game.
|
|
|
|
|
|
|
|
- Press space to progress arrow sprites.
|
|
|
|
''';
|
|
|
|
''';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
late final SpaceshipRamp _spaceshipRamp;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
await super.onLoad();
|
|
|
|
await super.onLoad();
|
|
|
|
await addFromBlueprint(SpaceshipRamp());
|
|
|
|
|
|
|
|
|
|
|
|
await images.loadAll([
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.railingBackground.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.main.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.boardOpening.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.railingForeground.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.arrow.inactive.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.arrow.active1.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.arrow.active2.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.arrow.active3.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.arrow.active4.keyName,
|
|
|
|
|
|
|
|
Assets.images.spaceship.ramp.arrow.active5.keyName,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_spaceshipRamp = SpaceshipRamp();
|
|
|
|
|
|
|
|
await addFromBlueprint(_spaceshipRamp);
|
|
|
|
camera.followVector2(Vector2(-12, -50));
|
|
|
|
camera.followVector2(Vector2(-12, -50));
|
|
|
|
await traceAllBodies();
|
|
|
|
await traceAllBodies();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
KeyEventResult onKeyEvent(
|
|
|
|
|
|
|
|
RawKeyEvent event,
|
|
|
|
|
|
|
|
Set<LogicalKeyboardKey> keysPressed,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (event is RawKeyDownEvent &&
|
|
|
|
|
|
|
|
event.logicalKey == LogicalKeyboardKey.space) {
|
|
|
|
|
|
|
|
_spaceshipRamp.progress();
|
|
|
|
|
|
|
|
return KeyEventResult.handled;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return KeyEventResult.ignored;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|