【问题标题】:Display number countdown before game starts c#游戏开始前显示数字倒计时c#
【发布时间】:2013-07-21 03:04:51
【问题描述】:

我的 windows 8 游戏是用 c# 创建的,它完成了它应该做的事情,但它不是在用户单击关卡时自动启动,而是开始倒计时。就像 3...2...1...去!类型的东西。但数字会出现并逐渐消失。

这里是渐变数字的故事板

 <Storyboard x:Name="FadeOut">
    <FadeOutThemeAnimation TargetName="Image1">
 <Storyboard/>

这个 xaml 代码确实适用于淡出,但我该怎么做才能让数字逐渐出现,然后在 4 秒内消失,我猜他们每个人都会显示并正式开始游戏?

【问题讨论】:

    标签: c# xaml windows-8


    【解决方案1】:

    FadeOutThemeAnimation 是一个内置的故事板,它可能不够灵活,无法满足您的需求,但您可以轻松创建自己的故事板(尤其是使用 Blend 时)。

    这是我模拟的一个似乎接近你想要的东西。它可以进行一些调整,特别是在淡入/淡出时间上,但您可以通过使用 XAML 中的 KeyTime 属性来修改这些。

        <Storyboard x:Name="Fader">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="textBlock">
                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:4.5" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" Storyboard.TargetName="textBlock">
                <DiscreteObjectKeyFrame KeyTime="0" Value="4"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="3"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="2"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:3" Value="1"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:4" Value="Go!"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    

    【讨论】:

      猜你喜欢
      • 2016-06-26
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多