mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-04 04:47:13 +08:00
feat: Adding FlameConsole (#3329)
Adding Flame Console package. --------- Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
This commit is contained in:
50
packages/flame_console/example/lib/main.dart
Normal file
50
packages/flame_console/example/lib/main.dart
Normal file
@ -0,0 +1,50 @@
|
||||
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),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user