Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void checkHit()
- {
- TouchCollection tc = TouchPanel.GetState();
- /* // Write the touch location to debug
- foreach (TouchLocation tl in tc)
- {
- if ((tl.State == TouchLocationState.Pressed)
- || (tl.State == TouchLocationState.Moved))
- {
- Debug.WriteLine(tl.Position.ToString());
- }
- }
- */ // End of touch debug checking
- if ((tc.Count > 0) && (tc[0].State == TouchLocationState.Pressed))
- {
- Point touchPoint = new Point((int)tc[0].Position.X, (int)tc[0].Position.Y);
- foreach (Sprite s in Sprites)
- {
- if (s.SpriteRectangle.Contains(touchPoint))
- {
- s.isAlive = false;
- return;
- }
- }
- /* // replaced with code above for simplicity, same problems occur
- for (int i = Sprites.Count - 1; i >= 0; i--)
- {
- Sprite sprite = Sprites[i];
- if (sprite.SpriteRectangle.Contains(touchPoint))
- {
- sprite.isAlive = false;
- break;
- }
- }
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement