match_magic/lib/screens/game_screen.dart

89 lines
2.6 KiB
Dart
Raw Normal View History

import 'package:flame/game.dart';
import 'package:flutter/material.dart';
import 'package:match_magic/game/board.dart';
import 'package:match_magic/screens/game_over_screen.dart';
import 'package:match_magic/screens/pause_screen.dart';
import 'package:match_magic/utilities/audio_manager.dart';
import 'package:match_magic/widgets/overlays/game_overlay/hint_button.dart';
import 'package:match_magic/widgets/overlays/game_overlay/pause_button.dart';
import 'package:match_magic/widgets/overlays/game_overlay/restart_button.dart';
class GameScreen extends StatefulWidget {
GameScreen(this.gameMode);
final bool gameMode;
@override
_GameScreenState createState() => _GameScreenState();
}
class _GameScreenState extends State<GameScreen> {
Board? board;
@override
void initState() {
super.initState();
AudioManager.load();
// AdManager.loadBannerAd();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
GameWidget(
initialActiveOverlays: [
PauseButton.id,
HintButton.id,
RestartButton.id
],
overlayBuilderMap: {
PauseButton.id: (BuildContext context, Board gameRef) =>
PauseButton(
gameRef: gameRef,
),
HintButton.id: (BuildContext context, Board gameRef) =>
HintButton(
gameRef: gameRef,
),
RestartButton.id: (BuildContext context, Board gameRef) =>
RestartButton(
gameRef: gameRef,
),
PauseMenu.id: (BuildContext context, Board gameRef) =>
PauseMenu(
gameRef: gameRef,
),
GameOverMenu.id: (BuildContext context, Board gameRef) =>
GameOverMenu(
gameRef: gameRef,
)
},
game: Board(
context,
gameMode: widget.gameMode,
)),
// Display Ads
// if (AdManager.bannerAd != null)
// Align(
// alignment: Alignment.bottomCenter,
// child: Container(
// width: AdManager.bannerAd!.size.width.toDouble(),
// height: AdManager.bannerAd!.size.height.toDouble(),
// child: AdWidget(ad: AdManager.bannerAd!),
// ),
// ),
],
),
);
}
}