Created
April 9, 2013 22:06
-
-
Save C4Code/5349843 to your computer and use it in GitHub Desktop.
Rotations, animations, and delays, oh my.
This file contains hidden or 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 Travis Kirton. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
NSMutableArray *shapes; | |
} | |
-(void)setup { | |
shapes = [@[] mutableCopy]; | |
for(int i = 0; i < 20; i++) { | |
C4Shape *s = [C4Shape rect:CGRectMake(0, 0, 20, 20)]; | |
s.anchorPoint = CGPointMake(0.5f,1.0f+i); | |
s.center = self.canvas.center; | |
[shapes addObject:s]; | |
} | |
[self.canvas addObjects:shapes]; | |
[self runMethod:@"setupAnimations" afterDelay:0.1f]; | |
} | |
-(void)setupAnimations { | |
for(int i = 0; i < [shapes count]; i++) { | |
C4Shape *s = shapes[i]; | |
s.animationDuration = i*.05f + 2.0f; | |
[self animateObject:s]; | |
} | |
} | |
-(void)animateObject:(C4Shape *)shape { | |
shape.animationDuration *= 0.99f; | |
shape.rotation += TWO_PI; | |
[self runMethod:@"animateObject:" withObject:shape afterDelay:shape.animationDuration+0.01f]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment