Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created February 27, 2013 18:41
Show Gist options
  • Save C4Code/5050412 to your computer and use it in GitHub Desktop.
Save C4Code/5050412 to your computer and use it in GitHub Desktop.
Animated Image
//
// C4WorkSpace.m
//
// Created by Travis Kirton
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace {
C4Image *still;
C4Image *animated;
}
-(void)setup {
[self setupImages];
still.mask = animated;
[self rotate];
}
-(void)rotate {
animated.animationOptions = REPEAT | LINEAR;
animated.animationDuration = 6.0f;
animated.rotation = TWO_PI;
}
-(void)setupImages {
still = [C4Image imageNamed:@"C4Sky"];
still.height = 240.0f;
still.center = self.canvas.center;
[self.canvas addImage:still];
//NOTE: You need to have the following images in your project
// You can replace these names with any image sequence
animated = [C4Image animatedImageWithNames:@[
@"C4Spin00.png",
@"C4Spin01.png",
@"C4Spin02.png",
@"C4Spin03.png",
@"C4Spin04.png",
@"C4Spin05.png",
@"C4Spin06.png",
@"C4Spin07.png",
@"C4Spin08.png",
@"C4Spin09.png",
@"C4Spin10.png",
@"C4Spin11.png"
]];
animated.center = CGPointMake(still.width/2,still.height/2);
animated.animatedImageDuration = 1.0f;
[self.canvas addSubview:animated];
[animated play];
}
-(void)touchesBegan {
if(animated.isAnimating == YES) [animated pause];
else [animated play];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment