Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. private void checkHit()
  2. {
  3. TouchCollection tc = TouchPanel.GetState();
  4. /* // Write the touch location to debug
  5. foreach (TouchLocation tl in tc)
  6. {
  7. if ((tl.State == TouchLocationState.Pressed)
  8. || (tl.State == TouchLocationState.Moved))
  9. {
  10. Debug.WriteLine(tl.Position.ToString());
  11. }
  12. }
  13. */ // End of touch debug checking
  14. if ((tc.Count > 0) && (tc[0].State == TouchLocationState.Pressed))
  15. {
  16. Point touchPoint = new Point((int)tc[0].Position.X, (int)tc[0].Position.Y);
  17. foreach (Sprite s in Sprites)
  18. {
  19. if (s.SpriteRectangle.Contains(touchPoint))
  20. {
  21. s.isAlive = false;
  22. return;
  23. }
  24. }
  25. /* // replaced with code above for simplicity, same problems occur
  26. for (int i = Sprites.Count - 1; i >= 0; i--)
  27. {
  28. Sprite sprite = Sprites[i];
  29. if (sprite.SpriteRectangle.Contains(touchPoint))
  30. {
  31. sprite.isAlive = false;
  32. break;
  33. }
  34. }
  35. */
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement