fix: trump trick
This commit is contained in:
@@ -31,6 +31,7 @@ class _GameScreenState extends State<GameScreen> {
|
||||
late final HokmGame _game;
|
||||
Timer? _introTimer;
|
||||
bool _introHidden = false;
|
||||
int _countdown = 0; // شمارشِ معکوسِ شروعِ بازی پس از یافتنِ حریفان (۳…۲…۱)
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -90,12 +91,23 @@ class _GameScreenState extends State<GameScreen> {
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state.state != null && _introTimer == null) {
|
||||
// کمی «حریفان پیدا شد» نشان بده، بعد اوورلی را کنار بزن و همان
|
||||
// لحظه انیمیشنِ بُر زدن (با صدا) را اجرا کن.
|
||||
_introTimer = Timer(const Duration(milliseconds: 1000), () {
|
||||
if (!mounted) return;
|
||||
setState(() => _introHidden = true);
|
||||
_game.endIntro();
|
||||
// حریفان پیدا شدند ⇒ شمارشِ معکوسِ ۳…۲…۱ با صدا تا کاربر بداند
|
||||
// بازی در حالِ شروع است، سپس اوورلی کنار میرود و بُر زدن اجرا میشود.
|
||||
_countdown = 3; // داخلِ build هستیم؛ همین build مقدار را نشان میدهد
|
||||
AppSounds.tick();
|
||||
_introTimer = Timer.periodic(const Duration(seconds: 1), (t) {
|
||||
if (!mounted) {
|
||||
t.cancel();
|
||||
return;
|
||||
}
|
||||
if (_countdown <= 1) {
|
||||
t.cancel();
|
||||
setState(() => _introHidden = true);
|
||||
_game.endIntro();
|
||||
} else {
|
||||
setState(() => _countdown--);
|
||||
AppSounds.tick();
|
||||
}
|
||||
});
|
||||
}
|
||||
return Stack(
|
||||
@@ -286,6 +298,42 @@ class _GameScreenState extends State<GameScreen> {
|
||||
'در حال یافتن حریفان…',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 13),
|
||||
),
|
||||
] else if (_countdown > 0) ...[
|
||||
const SizedBox(height: 14),
|
||||
const Text(
|
||||
'شروع بازی',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
TweenAnimationBuilder<double>(
|
||||
// هر عدد با یک «پاپ» ظاهر میشود تا واضح و جلبتوجه باشد.
|
||||
key: ValueKey(_countdown),
|
||||
tween: Tween(begin: 1.6, end: 1.0),
|
||||
duration: const Duration(milliseconds: 400),
|
||||
curve: Curves.easeOut,
|
||||
builder: (_, scale, child) =>
|
||||
Transform.scale(scale: scale, child: child),
|
||||
child: Container(
|
||||
width: 54,
|
||||
height: 54,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
gradient: const LinearGradient(
|
||||
colors: [AppColors.gold, AppColors.goldDark],
|
||||
),
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
),
|
||||
child: Text(
|
||||
'$_countdown',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF3A0A12),
|
||||
fontSize: 26,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user