Hello, i'm developping an application for kids (memory game): turning two same tiles(images) and you can remove them. the problem is how to turn the uiimages with animation and only the uiimages without turning the view that contain them.. do i have to put every uiimage in a small view? any ideas? PS :i'm not using OpenGL
A:
Sorry, misread the first time. Use UIImageViews for each tile and then animate as below.
a UIView is just a view, so you can animate it the way you animate any view. Its fairly straightforward.
UIImageView *tileToFlip = self.[tiles objectAtIndex:3];
CGRect frameOfTileToFlip = tileToFlip.frame;
UIImageView *newImageToShow = [[UIImageView alloc] initWithFrame:frameOfTileToFlip];
// add the image to newImageToShow
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:newImageToShow cache:NO];
[self.View addSubview:newImageToShow]; // I'm not sure if this is necessary
[UIView commitAnimations];
[tileToFlip removeFromSuperView]; // remove it so you can add it back later
Alternatively, you can use CATransition which gives you a little more control and different transitions.
joelm
2010-08-02 13:19:12
thank you for your answer, but by animating the view that contain the uiiamges views, the animation will be on all the view, not only the image i want..
2010-08-02 13:35:28
Sorry if I wasn't clear. You can animate JUST the UIimageView in question. Create a view filled with a (for example) 4x4 grid of UIImageViews. In each of these put your 'covered' image. Then when you want to flip one of them, create a new UIImageView with it's frame set to match the the UIImageView you want to flip, then add it to your view and do the transition I describe above. Later you can reverse the process and animate back the original 'cover view'. To be more efficient, you'd keep the 'picture' view around. (I edited the code to show I mean secondUIImageView)
joelm
2010-08-02 21:40:16
A:
thank you for your answer, but by animating the view that contain the uiiamges views, the animation will be on all the view, not only the image i want..