mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
29 lines
872 B
Dart
29 lines
872 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flame/input.dart';
|
|
import 'package:flame/palette.dart';
|
|
import 'package:flutter/painting.dart';
|
|
|
|
import 'joystick_player.dart';
|
|
|
|
class JoystickGame extends FlameGame with HasDraggables {
|
|
late final JoystickPlayer player;
|
|
late final JoystickComponent joystick;
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await super.onLoad();
|
|
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);
|
|
}
|
|
}
|