Need iPhone card flip effect , can't figure out how to do it
I'm writing a card game and need a animation to flip them over from one side to the other along the y axses. 开发者_如何学PythonWhat would be the easiest way to do this? Is there any good tutors? This is what I did:
Found some sample code for using UITransitionView. But it comes up as undeclared on my sdk, and I found out this was undocumented. Looked into OpenGL, seems to complicated.
Any help would be GREAT! Ted
Here is some code that I used in a blackjack app tutorial I went through:
-(void) flipCard {
[UIView beginAnimations:@"Flip Top Card" context:nil];
[UIView setAnimationDidStopSelector:@selector(flipCardDone)];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationRepeatCount:0];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut ];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:topCard cache:YES];
topCard.image = [UIImage imageNamed:@"back.png"]; //begin
topCard.image = [UIImage imageNamed:currentName]; //end
[UIView commitAnimations];
}
-(void) flipCardDone {
topCard.hidden = YES;
nextCardToFlip.hidden = NO; // bad var name, nextCardToFlip ONLY appears to flip.
}
I hope it helps you :)
The simplest way to do this would be to use UIView transitions, or CATransitions depending on what exactly you're trying to accomplish.
Documentation for the UIView animation can be found here.
精彩评论