2014-01-15 2 views
0

나는 C#을 사용하여 도약 동작과 WPF를 사용하여 제스처를 만든 횟수를 계산하려고합니다. 나는 버그가 부딪 칠 때마다 점수를 계산할 수있는 응용 프로그램을 가지고 있습니다. 이것은 지금 내 코드이지만 카운트가 잘못되었습니다. 나는 약간의 연구를했으며, 그것은 또한 제스처를하는 과정을 계산했기 때문에 그렇게 말하고있다. 도와주세요! 어떤 충고? 제스처가 만들어진 횟수를 세는 다른 간단한 방법을 알고 있다면 알려주시겠습니까 ??도약 모션 제스처 횟수 계산 횟수


private void ListenerOnOnGestureMade(GestureList gestureList) 

    { 
     foreach (var gesture in gestureList) 

     { 
      if (gesture.Type == Gesture.GestureType.TYPECIRCLE || gesture.Type == Gesture.GestureType.TYPESWIPE) 

      { 
       Dispatcher.Invoke(() => 

        { 
         SwipeGesture swipeGesture = new SwipeGesture(gesture); 
         var storyboard = (Storyboard)TryFindResource("finger-animation"); 
         storyboard.Begin(); 

         TryKillBugs(finger, 100, 60); 



        }); 
      } 

 private void TryKillBugs(UIElement image, int width, int height) 

    { 
     var fingerRect = new Rect 

     { 
      Location = image.PointToScreen(new Point(180, 0)), 
      Height = 200, 
      Width = 200 
     }; 

     foreach (var bug in bugs) 
     { 
      var bugRect = new Rect 
      { 
       Location = bug.PointToScreen(new Point(180, 0)), 
       Height = bug.ActualHeight, 
       Width = bug.ActualWidth 
      }; 

      if (fingerRect.IntersectsWith(bugRect)) 


       bug.Visibility = Visibility.Collapsed; 

      _killings++; 

     score.Text = (_killings).ToString(); 




     } 
    } 

답변

0

카운터 점진는 코드가 실제로 화면에

if (fingerRect.IntersectsWith(bugRect)) 
{ 
    bug.Visibility = Visibility.Collapsed; 
    _killings++; 
} 
+0

너무 많은 덕분에 모든 버그를 세고, if 내부해야합니다! 효과가있다. – user3098072