コード例 #1
0
        private void UpdatePosition(bool animated = true)
        {
            if (animated && enabled)
            {
                renderer.RunningAnimations += 2;

                System.Windows.Media.Animation.DoubleAnimation animX = new System.Windows.Media.Animation.DoubleAnimation(
                    gameObject.position.x * Renderer.FieldSize + renderer.offset.x, TimeSpan.FromSeconds(1));
                System.Windows.Media.Animation.DoubleAnimation animY = new System.Windows.Media.Animation.DoubleAnimation(
                    gameObject.position.y * Renderer.FieldSize + renderer.offset.y, TimeSpan.FromSeconds(1));

                animX.Completed += renderer.EndAnimation;
                translateTransform.BeginAnimation(System.Windows.Media.TranslateTransform.XProperty, animX);
                animY.Completed += renderer.EndAnimation;
                translateTransform.BeginAnimation(System.Windows.Media.TranslateTransform.YProperty, animY);
            }
            else
            {
                translateTransform.X = gameObject.position.x * Renderer.FieldSize + renderer.offset.x;
                translateTransform.Y = gameObject.position.y * Renderer.FieldSize + renderer.offset.y;
            }
        }
コード例 #2
0
        private void Rolling_Click()  //ф-я события  нажали кн. Roll-инг
        {
            double screenHeight = SystemParameters.FullPrimaryScreenHeight;
            //Height = screenHeight - 130;

            double screenWidth = SystemParameters.FullPrimaryScreenWidth;

            //Top = 100;
            //Left = 550;

            System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
            //da.From = 0;

            if (Grid2.Width > 20)
            {
                da.To       = 10;
                da.Duration = TimeSpan.FromSeconds(1);
                Grid2.BeginAnimation(Grid.WidthProperty, da);

                Grid2.Width = 10;

                System.Windows.Media.TranslateTransform trans = new System.Windows.Media.TranslateTransform();
                //Grid4.RenderTransform = trans;
                System.Windows.Media.Animation.DoubleAnimation anim1 = new System.Windows.Media.Animation.DoubleAnimation(0, -400, TimeSpan.FromSeconds(1));
                trans.BeginAnimation(System.Windows.Media.TranslateTransform.XProperty, anim1);

                Grid2.Width = 2 * (screenWidth / 3);
            }
            else
            {
                da.To       = 500;
                da.Duration = TimeSpan.FromSeconds(3);
                Grid2.BeginAnimation(Grid.WidthProperty, da);
                Grid2.Width = 500;
            }
        }