none
Devolver una animación RRS feed

  • Pregunta

  •         void Shoot_Completed(object sender, EventArgs e)
            {
                Check();
                RandomTenis();
            }
    
            void Choque_pelota(object sender, EventArgs e)
            {
                choqueCL.Begin();
                ChoqueCR.Begin();
                
            }
            private void Check()
            {
                   Rect goalKeeperRect = getGoalKeeperPosition();
                   Rect ballRect = getBallPosition();
    
                   goalKeeperRect.Intersect(ballRect);
                   if (goalKeeperRect.Width > 0 && goalKeeperRect.Height > 0)
                   {
                       // Not goal !!
                       tiros++;
                       Choque.Text = tiros.ToString();
                       
                      // Con esto devuelve la animación
                       MovePL.Completed += new EventHandler(Choque_pelota);
                       MovPCL.Completed += new EventHandler(Choque_pelota);
                   }
                   else
                   {
                       // goal
                   }
            }
    
            private void RandomTenis()
            {
                 Random random = new Random();
                 int indexAnimation = random.Next(1, 2);
    
                 switch (indexAnimation)
                 {
                     case 1:
                         MovePL.Begin();
                         break;
                     case 2:
                         MovPCL.Begin();
                         break;
                }
            }
             private Rect getGoalKeeperPosition()
             {
                 double? goalKeeperLeft = Raqueta.GetValue(Canvas.LeftProperty) as double?;
                 double? goalKeeperTop = Raqueta.GetValue(Canvas.TopProperty) as double?;
                 double goalKeeperWidth = Raqueta.Width;
                 double goalKeeperHeight = Raqueta.Height;
    
                 return new Rect(goalKeeperLeft.Value, goalKeeperTop.Value, goalKeeperWidth, goalKeeperHeight);
    
    
             }
             private Rect getBallPosition()
             {
                 GeneralTransform transform = Pelota.TransformToVisual(LayoutRoot);
                 Rect transformBounds = transform.TransformBounds(new Rect(0, 0, Pelota.ActualWidth, Pelota.ActualHeight));
                 return transformBounds;
             }
    
             private void Start_Click(object sender, RoutedEventArgs e)
             {
                 RandomTenis();
                 MovePL.Completed += new EventHandler(Shoot_Completed);
                 MovPCL.Completed += new EventHandler(Shoot_Completed);
                
             }
    
    Cuando devuelvo la pelota se queda en un bucle de que yo siempre devuelvo la pelota, alguien sabe como arreglarlo

    ___
    lunes, 5 de diciembre de 2011 10:56