Last active
December 14, 2015 12:18
-
-
Save gregtemp/5085876 to your computer and use it in GitHub Desktop.
touchesBegan (test example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// C4WorkSpace.m | |
// Examples | |
// | |
// Created by Greg Debicki. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Shape *s1, *s2; | |
} | |
-(void)setup { | |
[self setupShapes]; | |
} | |
-(void) setupShapes { | |
CGRect rect = CGRectMake(0, 0, 300, 75); | |
s1 = [C4Shape rect:rect]; | |
s2 = [C4Shape rect:rect]; | |
CGPoint currentCenter = self.canvas.center; | |
s1.center = currentCenter; | |
s2.center = currentCenter; | |
[self.canvas addShape:s1]; | |
[self.canvas addShape:s2]; | |
s1.animationDuration = 0.5f; | |
s2.animationDuration = 0.5f; | |
} | |
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | |
CGPoint touchedPoint = [[touches anyObject] locationInView:self.view]; | |
if (touchedPoint.y <= self.canvas.height/2) { | |
if (touchedPoint.x <= self.canvas.width/2){ | |
s2.rotation += PI/5.0f; | |
} | |
if (touchedPoint.x > self.canvas.width/2){ | |
s2.rotation -= PI/5.0f; | |
} | |
} | |
if (touchedPoint.y > self.canvas.height/2) { | |
if (touchedPoint.x <= self.canvas.width/2){ | |
s1.rotation += PI/5.0f; | |
} | |
if (touchedPoint.x > self.canvas.width/2){ | |
s1.rotation -= PI/5.0f; | |
} | |
} | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would add this:
... it shuts off user interaction for the duration of the animation.