コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: tolache/Invaders
 public MainPage()
 {
     InitializeComponent();
     _invadersViewModel = FindResource(nameof(InvadersViewModel)) as InvadersViewModel;
     InvadersHelper.BringToFront(GameOverText);
     InvadersHelper.BringToFront(PausedText);
 }
コード例 #2
0
        public void StartAnimation(IEnumerable <string> imageNames, TimeSpan interval)
        {
            Storyboard storyboard = new Storyboard();
            ObjectAnimationUsingKeyFrames animation = new ObjectAnimationUsingKeyFrames();

            Storyboard.SetTarget(animation, image);
            Storyboard.SetTargetProperty(animation, "Source");

            TimeSpan currentInteval = TimeSpan.FromMilliseconds(0);

            foreach (string imageName in imageNames)
            {
                ObjectKeyFrame keyFrame = new DiscreteObjectKeyFrame();
                keyFrame.Value   = InvadersHelper.CreateImageFromAssets(imageName);
                keyFrame.KeyTime = currentInteval;
                animation.KeyFrames.Add(keyFrame);
                currentInteval = currentInteval.Add(interval);
            }

            storyboard.RepeatBehavior = RepeatBehavior.Forever;
            storyboard.AutoReverse    = true;
            storyboard.Children.Add(animation);
            storyboard.Begin();
        }