فهرست منبع

Changed touch point rotation to be based on interface orientation

From initial comments I thought the desire was for device orientation, but upon looking at Game.cpp and comments again realized you wanted interface orientation on the touch points. This makes much more sense and is much easier then the custom extension I wrote.
Brandon Slack 14 سال پیش
والد
کامیت
e821160fa5
1فایلهای تغییر یافته به همراه6 افزوده شده و 40 حذف شده
  1. 6 40
      gameplay/src/PlatformiOS.mm

+ 6 - 40
gameplay/src/PlatformiOS.mm

@@ -36,40 +36,6 @@ static bool __shiftDown = false;
 long getMachTimeInMilliseconds(); 
 int getKey(unichar keyCode);
 
-@interface UITouch (RotationPointExtension)
-- (CGPoint)locationInViewWithRotation:(UIView *)view;
-@end
-@implementation UITouch (RotationPointExtension)
-- (CGPoint)locationInViewWithRotation:(UIView *)view 
-{
-    CGPoint touchLoc = [self locationInView:view];
-    CGPoint rotatedPoint = touchLoc;
-    if(view == nil) view = self.window; 
-    
-    if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) 
-    {
-        rotatedPoint.x = touchLoc.x;
-        rotatedPoint.y = touchLoc.y;
-    } 
-    else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) 
-    {
-        rotatedPoint.x = view.frame.size.width - touchLoc.x;
-        rotatedPoint.y = view.frame.size.height - touchLoc.y;
-    } 
-    else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
-    {
-        rotatedPoint.x = touchLoc.y;
-        rotatedPoint.y = view.frame.size.width - touchLoc.x;
-    } 
-    else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) 
-    {
-        rotatedPoint.x = view.frame.size.height - touchLoc.y;
-        rotatedPoint.y = touchLoc.x;
-    }
-    return rotatedPoint;
-}
-@end
-
 @interface View : UIView <UIKeyInput>
 {
     EAGLContext* context;	
@@ -339,8 +305,8 @@ int getKey(unichar keyCode);
     unsigned int uniqueTouch = 0;
     for(UITouch *t in touches) 
     {
-        CGPoint touchLoc = [t locationInViewWithRotation:nil];
-        Game::getInstance()->touchEvent(Touch::TOUCH_PRESS, touchLoc.y,  WINDOW_WIDTH - touchLoc.x, uniqueTouch);
+        CGPoint touchLoc = [t locationInView:self];
+        Game::getInstance()->touchEvent(Touch::TOUCH_PRESS, touchLoc.y,  touchLoc.x, uniqueTouch);
     }
 }
 
@@ -349,8 +315,8 @@ int getKey(unichar keyCode);
     unsigned int uniqueTouch = 0;
     for(UITouch* t in touches) 
     {
-        CGPoint touchLoc = [t locationInViewWithRotation:nil];
-        Game::getInstance()->touchEvent(Touch::TOUCH_RELEASE, touchLoc.y, WINDOW_WIDTH - touchLoc.x, uniqueTouch);
+        CGPoint touchLoc = [t locationInView:self];
+        Game::getInstance()->touchEvent(Touch::TOUCH_RELEASE, touchLoc.y, touchLoc.x, uniqueTouch);
     }
 }
 
@@ -366,8 +332,8 @@ int getKey(unichar keyCode);
     int uniqueTouch = 0;
     for(UITouch* t in touches) 
     {
-        CGPoint touchLoc = [t locationInViewWithRotation:nil];
-        Game::getInstance()->touchEvent(Touch::TOUCH_MOVE, touchLoc.y,  WINDOW_WIDTH - touchLoc.x, uniqueTouch);
+        CGPoint touchLoc = [t locationInView:self];
+        Game::getInstance()->touchEvent(Touch::TOUCH_MOVE, touchLoc.y,  touchLoc.x, uniqueTouch);
     }
 }