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 { 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 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); world.add(player); camera.viewport.add(joystick); } }