Created
July 25, 2012 19:20
-
-
Save C4Examples/3177990 to your computer and use it in GitHub Desktop.
Line End Points (Animated)
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 on 12-07-19. | |
| // | |
| #import "C4WorkSpace.h" | |
| @interface C4WorkSpace () | |
| -(void)animate; | |
| @end | |
| @implementation C4WorkSpace { | |
| C4Shape *line1, *line2, *line3; | |
| } | |
| -(void)setup { | |
| //create a set of default points for all the lines | |
| CGPoint linePoints[2]; | |
| linePoints[0] = CGPointMake(self.canvas.center.x-100, self.canvas.center.y); | |
| linePoints[1] = CGPointMake(linePoints[0].x+200, self.canvas.center.y); | |
| //create each line and style it, if necessary | |
| line1 = [C4Shape line:linePoints]; | |
| line2 = [C4Shape line:linePoints]; | |
| line2.strokeColor = C4BLUE; | |
| line3 = [C4Shape line:linePoints]; | |
| line3.strokeColor = C4GREY; | |
| //add all the lines to the canvas | |
| [self.canvas addShape:line3]; | |
| [self.canvas addShape:line2]; | |
| [self.canvas addShape:line1]; | |
| //animate them after a short delay | |
| [self runMethod:@"animate" afterDelay:0.1f]; | |
| } | |
| -(void)animate { | |
| //animate the line2 with a repeating 1 second animation | |
| line2.animationDuration = 1.0f; | |
| line2.animationOptions = AUTOREVERSE | REPEAT; | |
| CGPoint newPointA; | |
| newPointA = line2.pointA; | |
| newPointA.y += 200; | |
| line2.pointA = newPointA; | |
| //animate the line3 with a repeating 1 second animation | |
| line3.animationDuration = 1.0f; | |
| line3.animationOptions = AUTOREVERSE | REPEAT; | |
| CGPoint newPointB; | |
| newPointB = line3.pointB; | |
| newPointB.y -= 200; | |
| line3.pointB = newPointB; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment