Created
April 9, 2013 18:48
-
-
Save gregtemp/5348299 to your computer and use it in GitHub Desktop.
C4 Simple Random Movement
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. | |
// | |
@implementation C4WorkSpace { | |
C4Shape *circle; | |
} | |
-(void)setup { | |
circle = [C4Shape ellipse:CGRectMake(0, 0, 50, 50)]; | |
circle.center = self.canvas.center; | |
[self.canvas addShape:circle]; | |
[self runMethod:@"newPlace" afterDelay:0.0f]; | |
} | |
-(void)newPlace { | |
CGFloat time = ([C4Math randomInt:150]/100) + 0.5f; | |
circle.animationDuration = time; | |
circle.center = CGPointMake([C4Math randomInt:self.canvas.width/2] + self.canvas.width/4, | |
[C4Math randomInt:self.canvas.height/2] + self.canvas.height/4); | |
[self runMethod:@"newPlace" afterDelay:time]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment