Iphone UIImageView动画从顶部飞行

Iphone UIImageView动画从顶部飞行,iphone,Iphone,我正计划制作一款类似于《刽子手》的游戏。我希望每个角色都从顶部出现,就像从顶部飞行一样。我需要为这个实现进行转换还是仅仅硬编码动画 谢谢。将每个角色放在其自己的UIView实例中,并设置中心属性的动画 //let's say we have a custom UIView subclass that displays a character called 'MYCharacterView' MYCharacterView * view = [[MYCharacterView alloc] in

我正计划制作一款类似于《刽子手》的游戏。我希望每个角色都从顶部出现,就像从顶部飞行一样。我需要为这个实现进行转换还是仅仅硬编码动画


谢谢。

将每个角色放在其自己的UIView实例中,并设置
中心
属性的动画

//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];

希望有帮助

您需要调用
[UIView setAnimationDuration:2.0]在更改可设置动画的属性之前,因此它应该在
设置中心: