Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Mike Malz
1,421 PointsAnimation from "Image Based Animation" video isn't smooth
My code seems to be right from the video, but I don't get a smooth animation of the Crystal Ball.
5 Answers
TJ Bradley
Courses Plus Student 2,988 PointsI know its been 3 months Im writing this because i had the same issue and I'm just now finding out about it....the first 9 images have 4 zeros (CB00001). the rest have 3 (CB00010)
Amit Bijlani
Treehouse Guest TeacherIf you are seeing a jerk in the animation then I address the issue after 10.40 in the video.
Mike Malz
1,421 PointsYes, I had already replaced the starting image with CB00001. My animation doesn't just have a quirk at the beginning though, the entire sequence is VERY choppy. When I changed the FPS from 2.5f to 1, I saw a change, which led me to believe it's a framerate issue, but it still isn't as smooth as the animation you have in the video at all.
Amit Bijlani
Treehouse Guest TeacherI would just make sure you did not miss any images in the sequence while building the array or while copying the images to the project.
Mike Malz
1,421 PointsI did in fact miss one of the images, so I changed that. The animation still isn't smooth though. I can't figure out what else in the code would affect it.
Here's the code from the ViewController below:
(void)viewDidLoad { [super viewDidLoad]; self.crystalBall = [[MMCrystalBall alloc] init]; self.backgroundImageView.animationImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"CB00001"], [UIImage imageNamed:@"CB00002"], [UIImage imageNamed:@"CB00003"], [UIImage imageNamed:@"CB00004"], [UIImage imageNamed:@"CB00005"], [UIImage imageNamed:@"CB00006"], [UIImage imageNamed:@"CB00007"], [UIImage imageNamed:@"CB00008"], [UIImage imageNamed:@"CB00009"], [UIImage imageNamed:@"CB00010"], [UIImage imageNamed:@"CB00011"], [UIImage imageNamed:@"CB00012"], [UIImage imageNamed:@"CB00013"], [UIImage imageNamed:@"C000014"], [UIImage imageNamed:@"CB00015"], [UIImage imageNamed:@"CB00016"], [UIImage imageNamed:@"CB00017"], [UIImage imageNamed:@"CB00018"], [UIImage imageNamed:@"CB00019"], [UIImage imageNamed:@"CB00020"], [UIImage imageNamed:@"CB00021"], [UIImage imageNamed:@"CB00022"], [UIImage imageNamed:@"CB00023"], [UIImage imageNamed:@"CB00024"], [UIImage imageNamed:@"CB00025"], [UIImage imageNamed:@"CB00026"], [UIImage imageNamed:@"CB00027"], [UIImage imageNamed:@"CB00028"], [UIImage imageNamed:@"CB00029"], [UIImage imageNamed:@"CB00030"], [UIImage imageNamed:@"CB00031"], [UIImage imageNamed:@"CB00032"], [UIImage imageNamed:@"CB00033"], [UIImage imageNamed:@"CB00034"], [UIImage imageNamed:@"CB00035"], [UIImage imageNamed:@"CB00036"], [UIImage imageNamed:@"CB00037"], [UIImage imageNamed:@"CB00038"], [UIImage imageNamed:@"CB00039"], [UIImage imageNamed:@"CB00040"], [UIImage imageNamed:@"CB00041"], [UIImage imageNamed:@"CB00042"], [UIImage imageNamed:@"CB00043"], [UIImage imageNamed:@"CB00044"], [UIImage imageNamed:@"CB00045"], [UIImage imageNamed:@"CB00046"], [UIImage imageNamed:@"CB00047"], [UIImage imageNamed:@"CB00048"], [UIImage imageNamed:@"CB00049"], [UIImage imageNamed:@"CB00050"], [UIImage imageNamed:@"CB00051"], [UIImage imageNamed:@"CB00052"], [UIImage imageNamed:@"CB00053"], [UIImage imageNamed:@"CB00054"], [UIImage imageNamed:@"CB00055"], [UIImage imageNamed:@"CB00056"], [UIImage imageNamed:@"CB00057"], [UIImage imageNamed:@"CB00058"], [UIImage imageNamed:@"CB00059"], [UIImage imageNamed:@"CB00060"],nil]; self.backgroundImageView.animationDuration = 2.5f; self.backgroundImageView.animationRepeatCount = 1; }
(void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; }
pragma mark - Prediction
- (void) makePrediction { [self.backgroundImageView startAnimating]; self.predictionLabel.text = [self.crystalBall randomPrediction]; }
pragma mark - Motion Events
(void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { self.predictionLabel.text = nil; }
(void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if ( motion == UIEventSubtypeMotionShake ){ [self makePrediction]; } }
-(void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"motion cancelled"); }
pragma mark - Touch Events
(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { self.predictionLabel.text = nil; }
(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self makePrediction]; }
(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touches cancelled"); }
@end
TJ Bradley
Courses Plus Student 2,988 Pointsand it worked for me