Files
flame/examples/lib/stories/input/joystick_example.dart
Lukas Klingsbo 843ddc3624 refactor: Move to package imports (#1625)
* refactor: Move to package imports

* Fix local imports

* Removed unused imports
2022-05-15 15:04:35 +00:00

32 lines
1.1 KiB
Dart

import 'package:examples/stories/input/joystick_player.dart';
import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flame/palette.dart';
import 'package:flutter/painting.dart';
class JoystickExample extends FlameGame with HasDraggables {
static const String description = '''
In this example we showcase how to use the joystick by creating simple
`CircleComponent`s that serve as the joystick's knob and background.
Steer the player by using the joystick.
''';
late final JoystickPlayer player;
late final JoystickComponent joystick;
@override
Future<void> onLoad() async {
final knobPaint = BasicPalette.blue.withAlpha(200).paint();
final backgroundPaint = BasicPalette.blue.withAlpha(100).paint();
joystick = JoystickComponent(
knob: CircleComponent(radius: 30, paint: knobPaint),
background: CircleComponent(radius: 100, paint: backgroundPaint),
margin: const EdgeInsets.only(left: 40, bottom: 40),
);
player = JoystickPlayer(joystick);
add(player);
add(joystick);
}
}