update:倒计时bug'

This commit is contained in:
ltx 2026-02-24 13:19:21 +08:00
parent d9e2a90a22
commit c6c50f3d6a
5 changed files with 59 additions and 39 deletions

View File

@ -175,7 +175,8 @@ namespace Wpf_AiSportsMicrospace
else
{
//var newPage = new TrainingRecords();
var newPage = new WhackAMole();
//var newPage = new WhackAMole();
var newPage = new StandingLeap();
mainWin?.SwitchPageWithMaskAnimation(newPage, true);
}
}

View File

@ -25,7 +25,9 @@
x:Name="centerImg4"
Visibility="Hidden"
gif:ImageBehavior.AnimatedSource="/Resources/Img/test_img/jump_long/jumping.gif"
gif:ImageBehavior.RepeatBehavior="0"
gif:ImageBehavior.RepeatBehavior="1x"
gif:ImageBehavior.AutoStart="False"
gif:ImageBehavior.AnimationSpeedRatio="1.5"
gif:ImageBehavior.AnimateInDesignMode="True"
HorizontalAlignment="Left" VerticalAlignment="Top" Margin="824,72,0,0" Width="824" Height="610"/>
<Grid Width="1920" Height="1080" Background="#80000000" x:Name="TipBox" Opacity="0">

View File

@ -230,7 +230,7 @@ namespace Views.JumpLong
ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(2));
ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(1));
ImageBehavior.GetAnimationController(centerImg4).Play();
await Task.Delay(800);
await Task.Delay(2100);
_sport.Stop();//关闭运动
_mainWin.FacialRecognitionEvent -= this.HumanPredicting;
count.Text = counts;

View File

@ -226,13 +226,13 @@ namespace Wpf_AiSportsMicrospace.Views
StartCountdown(3);
_isCountdownStarted = true; // 倒计时开始,停止左手检测
break;
case (int)WavingAction.Raising:
UpdateCountdown();
break;
case (int)WavingAction.RaiseHand:
FinishCountdown();
_currentGameState = GameState.Running; // 倒计时完成 → 游戏开始
break;
//case (int)WavingAction.Raising:
// UpdateCountdown();
// break;
//case (int)WavingAction.RaiseHand:
// FinishCountdown();
// _currentGameState = GameState.Running; // 倒计时完成 → 游戏开始
// break;
}
}
break;
@ -246,7 +246,7 @@ namespace Wpf_AiSportsMicrospace.Views
private double _currentCountdown = 3600;
private DateTime _lastUpdateTime = DateTime.Now;
private void StartCountdown(int start = 3)
private async void StartCountdown(int start = 3)
{
_mainWin.ShowCountDownAnimation();
//_currentCountdown = start;
@ -289,6 +289,10 @@ namespace Wpf_AiSportsMicrospace.Views
// 绑定事件
_mainWin.FacialRecognitionEvent += handler;
await Task.Delay(3000);
FinishCountdown();
_currentGameState = GameState.Running;
}
private void UpdateCountdown()

View File

@ -201,15 +201,18 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
switch (rightWaving)
{
case (int)WavingAction.FirstHand:
StartCountdown(3);
_isCountdownStarted = true;
if (!_isCountdownStarted)
{
StartCountdown(3);
}
break;
case (int)WavingAction.Raising:
UpdateCountdown();
//UpdateCountdown();
break;
case (int)WavingAction.RaiseHand:
FinishCountdown();
_currentGameState = GameState.Running;
//FinishCountdown();
//_currentGameState = GameState.Running;
break;
}
}
@ -230,15 +233,18 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
private int _currentCountdown = 3;
private DateTime _lastUpdateTime = DateTime.Now;
private void StartCountdown(int start = 4)
private async void StartCountdown(int start = 4)
{
_mainWin.ShowCountDownAnimation();
_isCountdownStarted = true;
_currentCountdown = start;
//countdownText.Text = _currentCountdown.ToString();
//countdownGrid.Visibility = Visibility.Visible;
_lastUpdateTime = DateTime.Now;
_mainWin.ShowCountDownAnimation();
Utils.PlayBackgroundMusic("countdown_3.mp3", false);
//UpdateCountdown();
//开始人脸识别=============================================
Action<VideoFrame> handler = null;
@ -269,8 +275,31 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
// 这里可以继续处理 studentList
};
// 绑定事件
//// 绑定事件
_mainWin.FacialRecognitionEvent += handler;
await Task.Delay(3000);
FinishCountdown();
_currentGameState = GameState.Running;
}
private void UpdateCountdown()
{
if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= 1)
{
_lastUpdateTime = DateTime.Now;
_currentCountdown--;
if (_currentCountdown > 0)
{
countdownText.Text = _currentCountdown.ToString();
}
else
{
FinishCountdown();
_currentGameState = GameState.Running;
}
}
}
private async Task LoadImageFromUrlAsync(string imageUrl, Image image)
@ -301,24 +330,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
}
}
private void UpdateCountdown()
{
if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= 1)
{
_lastUpdateTime = DateTime.Now;
_currentCountdown--;
if (_currentCountdown > 0)
{
countdownText.Text = _currentCountdown.ToString();
}
else
{
FinishCountdown();
}
}
}
private async void FinishCountdown()
{
countdownText.Text = "GO!";
@ -593,8 +604,10 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
private void Image_MouseDown(object sender, MouseButtonEventArgs e)
{
popSilder1.StartMarginAnimation();
popSilder2.StartMarginAnimation();
//popSilder1.StartMarginAnimation();
//popSilder2.StartMarginAnimation();
//StartCountdown();
StartCountdown(3);
}
}
}