我打算创建像刽子手这样的游戏。而且我希望每个角色都从顶部出现,就像从顶部飞来一样。我是否必须进行转换或仅为此实现编写动画代码?
感谢。
答案 0 :(得分:3)
将每个字符放在自己的UIView实例中,并为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];
希望有所帮助!