mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 20:13:50 +08:00
51 lines
1.1 KiB
Dart
51 lines
1.1 KiB
Dart
import 'package:flame/game.dart';
|
|
import 'package:flame_console/flame_console.dart';
|
|
import 'package:flame_console_example/game.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(const MaterialApp(home: MyGameApp()));
|
|
}
|
|
|
|
class MyGameApp extends StatefulWidget {
|
|
const MyGameApp({super.key});
|
|
|
|
@override
|
|
State<MyGameApp> createState() => _MyGameAppState();
|
|
}
|
|
|
|
class _MyGameAppState extends State<MyGameApp> {
|
|
late final MyGame _game;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_game = MyGame();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: GameWidget(
|
|
game: _game,
|
|
overlayBuilderMap: {
|
|
'console': (BuildContext context, MyGame game) => ConsoleView(
|
|
game: game,
|
|
onClose: () {
|
|
_game.overlays.remove('console');
|
|
},
|
|
),
|
|
},
|
|
),
|
|
floatingActionButton: FloatingActionButton(
|
|
heroTag: 'console_button',
|
|
onPressed: () {
|
|
_game.overlays.add('console');
|
|
},
|
|
child: const Icon(Icons.developer_mode),
|
|
),
|
|
);
|
|
}
|
|
}
|