Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created February 7, 2013 06:15
Show Gist options
  • Save C4Code/4728929 to your computer and use it in GitHub Desktop.
Save C4Code/4728929 to your computer and use it in GitHub Desktop.
Don't know what to call this one...
//
// AnimatedShape.h
// C4iOS
//
// Created by Travis Kirton and Greg Debicki.
//
#import "C4Shape.h"
@interface AnimatedShape : C4Shape
-(void)startAnimation;
-(AnimatedShape *)copyWithZone:(NSZone *)zone;
@end
//
// AnimatedShape.m
// C4iOS
//
// Created by moi on 13-02-06.
// Copyright (c) 2013 POSTFL. All rights reserved.
//
#import "AnimatedShape.h"
@implementation AnimatedShape {
C4Shape *s;
}
-(void)setup {
self.fillColor = [UIColor clearColor];
self.lineWidth = 1.0f;
s = [C4Shape ellipse:CGRectMake(0, 0, 15, 15)];
s.alpha = 0.0f;
s.center = CGPointZero;
s.lineWidth = 0.0f;
[self addShape:s];
}
-(void)startAnimation {
s.animationDuration = 2.0f;
s.animationOptions = AUTOREVERSE | REPEAT;
s.center = CGPointMake(self.width, 0);
s.alpha = 1.0f;
}
-(AnimatedShape *)copyWithZone:(NSZone *)zone {
AnimatedShape *as = [[AnimatedShape allocWithZone:zone] initWithFrame:self.frame];
as.style = self.style;
return as;
}
@end
//
// C4WorkSpace.m
//
// Created by Travis Kirton and Greg Debicki.
//
#import "C4WorkSpace.h"
#import "AnimatedShape.h"
@implementation C4WorkSpace {
NSMutableArray *shapes;
C4Timer *t;
}
-(void)setup {
shapes = [[NSMutableArray alloc] initWithCapacity:0];
for(int i = 0; i < 32; i++) {
AnimatedShape *as = [[AnimatedShape alloc] initWithFrame:CGRectMake(0, 0, 276, 1)];
as.anchorPoint = CGPointZero;
as.center = self.canvas.center;
as.rotation = (CGFloat)i / 32.0f * TWO_PI;
[as runMethod:@"startAnimation" afterDelay:4.0f*(CGFloat)i/32.0f];
[shapes addObject:as];
}
[self.canvas addObjects:shapes];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment