12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import 'package:battle/button/button_controller.dart';
- import 'package:flutter/material.dart';
- import 'package:widget/widget.dart';
- import '../button/button_painter.dart';
- class GamePage extends StatefulWidget {
- const GamePage({super.key});
- @override
- State<GamePage> createState() => _GamePageState();
- }
- class _GamePageState extends State<GamePage> with SingleTickerProviderStateMixin {
- late ButtonController _controller;
- @override
- void initState() {
- super.initState();
- _controller = ButtonController(vsync: this);
- _controller.start();
- }
- void _reset() {
- _controller.reset();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Stack(
- children: [
- Positioned.fill(
- child: ColorFiltered(
- colorFilter: const ColorFilter.matrix(<double>[
- 1, 0, 0, 0, 0, //r
- 0, 1, 0, 0, 0, //r
- 0, 0, 1, 0, 0, //r
- 0, 0, 0, 0.25, 0, //r
- ]),
- child: Image.asset(
- 'assets/images/background.png',
- repeat: ImageRepeat.repeat,
- cacheWidth: 30,
- cacheHeight: 30,
- ),
- ),
- ),
- Positioned.fill(
- child: Column(
- children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: BattleBoard(
- card: ClipRRect(
- borderRadius: BorderRadius.circular(8),
- child: Container(
- color: Colors.grey,
- ),
- ),
- button: CustomPaint(
- painter: ButtonPainter(controller: _controller),
- child: const SizedBox.expand(),
- ),
- ),
- ),
- ),
- TextButton(
- onPressed: () {
- _reset();
- },
- child: const Text('重新开始'),
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }
- }
|