I'm trying to make a simple Simon game (an increasing sequence of colors flash and the user has to try to repeat that sequence). The way I'm going about it is by having 4 UIViews with 8 images. So there's a UIView for red, blue, green, and yellow. And I have gifs of dark green, light green, dark red, light red, etc.
So in my code, I'm using UIView's transitionWithView animation block: The UIView imageView.image is defaulted to the dark color image and this block is transitioning to light colored image, and on completion going back to the dark color image (to give it a "lighting up" look).
- (void) animateColor:(NSString *)color
{
...
//do stuff to default the dark and light image name and which UIView to animate based on the color parameter
...
[UIView transitionWithView:imageView
duration:.5
options: UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAutoreverse
animations:^{
imageView.image = [UIImage imageNamed:lightImage];
}
completion:^(BOOL finished){
if (finished){
imageView.image = [UIImage imageNamed:darkImage];
}
}];
}
This works fine when I call it the method this code in with one color.
The problem is, say I have an NSArray or colors I want to animate sequentially. So if my array was "blue","green" I would want the transitionWithView to be called using blue, animate the blue view, then animate the green view. Right now, it will animate the green view and the blue view at the same time.
I'm trying to play around with NSTimer right now, but not having much luck with that.
Any advice out there would be much appreciated.