Je crée un jeu de cartes sur iphone.Animer plusieurs UIView dans un cycle
Mon problème est que je veux animer les cartes au début du jeu en faisant animer les cartes d'un point à un autre point dans un paquet.
Je déplace mes cartes qui sont UIView, dans un cycle. c'est ce que je fais
Avec ce code, toutes les cartes se déplacent ensemble, je dois déplacer les cartes séparément l'un après l'autre
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];
}
dans la vue de la carte il y a ces méthodes
-(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];
}
Merci, je essayé, courir, mais le flux de mouvement est non régulier, une vue toghether déplacer. merci encore – Giovanni
OK, Résolu, en utilisant i/40.4 comme délai. Merci beaucoup – Giovanni