2009-11-11 4 views
1

Je prévois de créer un jeu comme bourreau. Et je veux que chaque personnage apparaisse du haut, comme voler du haut. Dois-je faire une transition ou simplement coder l'animation pour cette implémentation?UIImageView animation volant de haut

Merci.

Répondre

3

Placez chaque caractère dans sa propre instance UIView et animez la propriété center.

//let's say we have a custom UIView subclass that displays a character called 'MYCharacterView' 

MYCharacterView * view = [[MYCharacterView alloc] initWithFrame:CGRectMake(50.0, -10.0, 20.0, 20.0); 
// ... configure the view here, e.g., set the character, etc. ... 
[UIView beginAnimations:nil context:nil]; 
//animate the view from its current position off the top of the screen to 50, 200 
//over 2 seconds 
[view setCenter:CGPointMake(50.0, 200.0)]; 
[UIView setAnimationDuration: 2.0]; 
[UIView commitAnimations]; 

Espérons que ça aide!

+0

Vous devez appeler '[UIView setAnimationDuration: 2.0];' avant de modifier les propriétés animables, donc il doit être avant 'setCenter:' –