2009-11-11 4 views
1

행맨 (hangman)과 같은 게임을 만들 계획입니다. 그리고 모든 캐릭터가 위에서부터 날아 오는 것처럼 보이기를 바랍니다. 이 구현을 위해 애니메이션을 변환하거나 하드 코딩해야합니까?UIImageView 애니메이션이 위에서 튀어 오름

감사합니다.

답변

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

희망 하시겠습니까?

+0

animatable 속성을 변경하기 전에'[UIView setAnimationDuration : 2.0];'을 호출해야하므로'setCenter :' –

관련 문제