mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-20 23:17:27 +08:00
Renamed doc to docs and minor language fixes
This commit is contained in:
38
docs/examples/with_widgets_overlay/lib/example_game.dart
Normal file
38
docs/examples/with_widgets_overlay/lib/example_game.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/gestures.dart';
|
||||
import 'package:flame/palette.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExampleGame extends Game with HasWidgetsOverlay, TapDetector {
|
||||
bool isPaused = false;
|
||||
|
||||
@override
|
||||
void update(double dt) {}
|
||||
|
||||
@override
|
||||
void render(Canvas canvas) {
|
||||
canvas.drawRect(const Rect.fromLTWH(100, 100, 100, 100),
|
||||
Paint()..color = BasicPalette.white.color);
|
||||
}
|
||||
|
||||
@override
|
||||
void onTap() {
|
||||
if (isPaused) {
|
||||
removeWidgetOverlay('PauseMenu');
|
||||
isPaused = false;
|
||||
} else {
|
||||
addWidgetOverlay(
|
||||
'PauseMenu',
|
||||
Center(
|
||||
child: Container(
|
||||
width: 100,
|
||||
height: 100,
|
||||
color: const Color(0xFFFF0000),
|
||||
child: const Center(child: const Text('Paused')),
|
||||
),
|
||||
));
|
||||
isPaused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user