Hi all, i'm creating a card game on iphone.
My problem is that i want to animate the cards at the beginning of the game making the cards animate from a point to another point in a deck.
I move my cards that are UIView, in afor cicle. this is what i do
With this code, alla tha cards move together, i need to move the cards separately one after another
CGPoint point;
// Create the deck of playing cards
for (int i = 0; i < 28; i++) {
CardView *aCardView = [self.mazzo objectAtIndex:i];
point.x = -100;
point.y = 200;
aCardView.center = point;
aCardView.zPosition = i;
[self.viewGioco addSubview:aCardView];
[aCardView release];
//Here i call the method to position the card
[aCardView positionCard];
}
in the card view there are this methods
-(void)positionCard{
[self performSelector:@selector(_positionCard) withObject:nil afterDelay:0.0];
}
-(void)_positionCard{
[UIView beginAnimations:@"posizionacarta" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.3f];
CGPoint point;
point.x = 280 + ((arc4random() % 2) - 1);
point.y = 240 + ((arc4random() % 2) - 1);
self.center = point;
[UIView commitAnimations];
[self setNeedsLayout];
}