update:动画&位置bug

This commit is contained in:
ltx 2025-10-21 14:58:40 +08:00
parent 3e0e128ed1
commit 98c003e4d5
7 changed files with 65 additions and 11 deletions

View File

@ -9,14 +9,14 @@
>
<Grid>
<Grid x:Name="great" Visibility="Hidden" HorizontalAlignment="Left" Height="172" Width="221" VerticalAlignment="Bottom" Margin="-110,0,0,0" >
<Grid x:Name="great" Visibility="Hidden" Panel.ZIndex="1000" HorizontalAlignment="Left" Height="172" Width="221" VerticalAlignment="Bottom" Margin="-105,0,0,0" >
<Image Source="/Resources/Img/play_img/music_rope/great.png" HorizontalAlignment="Right" Width="90" VerticalAlignment="Top" Margin="0,0,0,0"/>
<Image Source="/Resources/Img/play_img/music_rope/great-p.png" Width="145" Height="141" VerticalAlignment="Bottom" />
</Grid>
<Image x:Name="miss" Source="/Resources/Img/play_img/music_rope/miss.png" Visibility="Hidden" HorizontalAlignment="Left" Width="157" Height="85" VerticalAlignment="Bottom" Margin="0,0,0,86"/>
<Image x:Name="head_g" Source="/Resources/Img/play_img/music_rope/head_g.png" Visibility="Visible" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
<Image x:Name="head_m" Source="/Resources/Img/play_img/music_rope/head_m.png" Visibility="Visible" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
<Image x:Name="head_g" Source="/Resources/Img/play_img/music_rope/head_g.png" Visibility="Hidden" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
<Image x:Name="head_m" Source="/Resources/Img/play_img/music_rope/head_m.png" Visibility="Hidden" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Grid Width="3" Height="140" Background="#fedd40" ClipToBounds="False" Margin="0,500,0,0"></Grid>
<Grid Width="580" Height="87" Background="#25ffffff" ClipToBounds="False" Margin="0,500,0,0" HorizontalAlignment="Left">

View File

@ -163,14 +163,14 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
private void OnTimePointReached(double timePoint)
{
Console.WriteLine($"触发时间点: {timePoint}");
if (_isMiss)
if (isMiss)
{
head_m.Visibility = Visibility.Visible;
miss.Visibility = Visibility.Visible;
head_g.Visibility = Visibility.Hidden;
great.Visibility = Visibility.Hidden;
// 200ms 后隐藏
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) };
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(300) };
hideTimer.Start();
hideTimer.Tick += (s, e) =>
{
@ -185,8 +185,10 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
great.Visibility = Visibility.Visible;
head_m.Visibility = Visibility.Hidden;
miss.Visibility = Visibility.Hidden;
ShowImageWithAnimation(great , 221 , 172);
ShowImageWithAnimation(head_g , 152 , 82);
// 200ms 后隐藏
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) };
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(300) };
hideTimer.Start();
hideTimer.Tick += (s, e) =>
{
@ -197,6 +199,44 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
};
}
}
private void ShowImageWithAnimation(UIElement ui , int width, int height)
{
// 透明度动画
DoubleAnimation opacityAnimation = new DoubleAnimation
{
From = 0,
To = 1,
Duration = TimeSpan.FromSeconds(0.1)
};
// 缩放动画
DoubleAnimation scaleYAnimation = new DoubleAnimation
{
From = height - 12,
To = height + 12,
Duration = TimeSpan.FromSeconds(0.3),
EasingFunction = new ElasticEase { EasingMode = EasingMode.EaseOut }
};
DoubleAnimation scaleXAnimation = new DoubleAnimation
{
From = width - 30,
To = width + 20,
Duration = TimeSpan.FromSeconds(0.3),
EasingFunction = new ElasticEase { EasingMode = EasingMode.EaseOut}
};
ui.BeginAnimation(Image.OpacityProperty, opacityAnimation);
ui.BeginAnimation(Image.WidthProperty, scaleXAnimation);
ui.BeginAnimation(Image.HeightProperty, scaleYAnimation);
//ui.BeginAnimation(RotateTransform.AngleProperty, rotateAnimation);
}
}
public class TimedEventTrigger

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -57,12 +57,22 @@
<Image
gif:ImageBehavior.AnimatedSource="/Resources/Img/Album/1.gif"
gif:ImageBehavior.RepeatBehavior="Forever"
HorizontalAlignment="right"
VerticalAlignment="Top"
HorizontalAlignment="right"
VerticalAlignment="Top"
Margin="50,10,200,20"
/>
</Grid>
</Grid>
<Image
gif:ImageBehavior.AnimatedSource="/Resources/Img/Album/leight.gif"
gif:ImageBehavior.RepeatBehavior="Forever"
gif:ImageBehavior.AnimateInDesignMode="True"
VerticalAlignment="Top"
Margin="20,80,0,0"
Width="880"
/>
</Grid>
</UserControl>

View File

@ -326,8 +326,8 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
lose1.Margin = new Thickness(60, 0, 0, 0);
lose2.Margin = new Thickness(60, 0, 0, 0);
lose3.Margin = new Thickness(60, 0, 0, 0);
win1.Margin = new Thickness(60, -123, 0, 0);
win2.Margin = new Thickness(60, -123, 0, 0);
win1.Margin = new Thickness(980, -123, 0, 0);
win2.Margin = new Thickness(980, -123, 0, 0);
text1.Text = "LOSE";
text2.Text = "WIN";

View File

@ -27,6 +27,7 @@
<None Remove="Resources\Img\Album\home_history.png" />
<None Remove="Resources\Img\Album\home_play.png" />
<None Remove="Resources\Img\Album\home_test.png" />
<None Remove="Resources\Img\Album\leight.gif" />
<None Remove="Resources\Img\Album\title.png" />
<None Remove="Resources\Img\Album\vs.png" />
<None Remove="Resources\Img\Badge\1.jpg" />
@ -97,6 +98,9 @@
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Img\Album\leight.gif">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\Img\play_img\music_rope\back.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>