hedgewars/uTouch.pas
branchhedgeroid
changeset 5615 104f69e798bb
parent 5609 9d66611e4d0a
child 5617 88f43becefe3
--- a/hedgewars/uTouch.pas	Fri Aug 19 22:31:59 2011 +0200
+++ b/hedgewars/uTouch.pas	Fri Aug 19 22:40:13 2011 +0200
@@ -28,6 +28,7 @@
 
 function findFinger(id: SDL_FingerId): Touch_Finger;
 procedure aim(finger: Touch_Finger);
+function isOnCrosshair(finger: Touch_Finger): boolean;
 function isOnCurrentHog(finger: Touch_Finger): boolean;
 function isOnFireButton(finger: Touch_Finger): boolean;
 procedure convertToWorldCoord(var x,y: hwFloat; finger: Touch_Finger);
@@ -87,7 +88,7 @@
                 exit;
             end;
 
-            if isOnCurrentHog(finger) then
+            if isOnCrosshair(finger) then
             begin
                 aiming:= true;
                 exit;
@@ -358,6 +359,17 @@
     isOnFireButton:= (finger.x < 150) and (finger.y > 390);
 end;
 
+function isOnCrosshair(finger: Touch_Finger): boolean;
+var
+    x,y,fingerX, fingerY : hwFloat;
+begin
+    x := int2hwFloat(CrosshairX);
+    y := int2hwFloat(CrosshairY);
+
+    convertToWorldCoord(fingerX, fingerY, finger);
+    isOnCrosshair:= Distance(fingerX-x, fingerY-y) < _20;
+end;
+
 function isOnCurrentHog(finger: Touch_Finger): boolean;
 var
     x,y, fingerX, fingerY : hwFloat;