Search code examples
iphonecocos2d-iphoneuiviewanimationplaying-cards

flipping cards in a card game


I develop a game where when user touches a card it'll flip slowly and number will show up. For that purpose , what cocos2d API can I use ?

Or should I create animation with frames indicating the flip?


Solution

  • For Flipping a view u can do it like this ,

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.6];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:myview cache:YES];
    [UIView commitAnimations];
    

    Before doing animation just create a label and add it as a subview to the UIView. Set the text to the number u want to display after the animation.Hide this label.At the end of the animation that is after commitAnimations just set the hidden property of the label to NO. You will achieve the animation style u want , i guess.. Hope this helps....Happy coding... :)