
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 1.31 KB | hits: 12 | expires: Never
Move a CGPoint dependant on device orientation
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if ( (self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) ) {
myPoint = CGPointMake(320/460*myPoint.x, 460/320*myPoint.y);
}
else {
myPoint = CGPointMake(460/320*myPoint.x, 320/460*myPoint.y);
}
}
- (CGPoint)adjustTouch:(CGPoint)aTouch forOrientation:(UIInterfaceOrientation)aOrientation; {
CGPoint touchLocation = CGPointZero;
switch (aOrientation) {
case UIInterfaceOrientationPortrait:
touchLocation = aTouch;
break;
case UIInterfaceOrientationPortraitUpsideDown:
touchLocation.x = aTouch.x;
touchLocation.y = 480 - aTouch.y;
break;
case UIInterfaceOrientationLandscapeLeft:
touchLocation.x = aTouch.y;
touchLocation.y = aTouch.x;
break;
case UIInterfaceOrientationLandscapeRight:
touchLocation.x = 480 - aTouch.y;
touchLocation.y = 320 - aTouch.x;
break;
default:
break;
}
return touchLocation;
}