Hey,
I have looked through about 12 pages of Game Development and couldnt find a solution, so here is my problem.
Im trying to create a color wheel that rotates to the next color when navigation button is pressed.
So, everything to do with navigation is fine, got that down pretty good by now but i am using something new to me and its driving me mental.
The things new to me are the <QuartzCore/QuartzCore.h> framework and CABasicAnimation with transform.rotation. So, i figured out how to make a single image spin, which is cool, but not what i want yet.
I can get the wheel to spin say 90 degrees then load the next view, (with the buttons and labels ect.) but when the wheel spins again there is an image of the wheel behind the animation! I cant get rid of it without doing removeFromSuperview, (i cant seem to get it back again after that.)
Here is my code:
Code:
// This bit removes a view with a static image of the color wheel at start position.
...[flip1View1 removeFromSuperview];
UIImage *image = [UIImage imageNamed:@"Rainbow4.png"];
UIImageView *imgView =[[UIImageView alloc] initWithImage:image];
[imgView setFrame:(CGRect){{0,0},image.size}];
[imgView setCenter:(CGPoint){0,240}];
[self addSubview:imgView];
// So i have got my image on screen and its about to spin 90 degrees.
CABasicAnimation * rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotationAnimation.fromValue = [NSNumber numberWithFloat:0];
rotationAnimation.toValue = [NSNumber numberWithFloat:((90*M_PI)/180)];
rotationAnimation.duration = 2;
[imgView.layer addAnimation:fullRotation forKey:@"360"];
[self performSelector:@selector(loadNextView) withObject:nil afterDelay:2.00];
}
// When 2 seconds have passed, load the next view. The next view has a static image of the color wheel rotated 90 degrees, its pretty seamless.
- (void) loadNextView {
[self addSubview:flip1View2];
}
When using this code, an image of the color wheel appears in the background of the next spin. (Only time it works is the first time.)
I would like to know how to have it so the First View loads... Next(Button Press)... Animation... Second View loads... Next(Button Press)... Animation... ect. If i use removeFromSuperview then i cannot use the animation again...
Any ideas on how to release the animation so that it is loaded fresh everytime?
This way i would be able to give the animation a different start position for the direction they are navigating.
Thank You
Alex