이미지를 특정 위치로 이동하고 싶습니다. 또한 이미지의 특정 위치에 도달했는지 여부에 관계없이 매초마다 이미지의 현재 위치를 확인해야합니다. 그래서, 나는 다음과 같은 한 :UIView 애니메이션을 중지하지 않고 이미지의 현재 위치
-(void)viewWillAppear:(BOOL)animated{
[self moshaMoveUp:mosha1 with:206 and:89];
playerLifeCount = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(deductPlayerLife) userInfo:nil repeats:YES];
}
-(void)moshaMoveUp: (UIImageView *)mosha with:(int)x and:(int)y{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:7.0];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
mosha.center = CGPointMake(x, y);
[UIView commitAnimations];
}
그러나 문제는 'moshaMoveUp'방법은 처음에 호출 될 때, 이미지의 중심이 그 시간에 (206,89)로 설정되어 있습니다. 그래서, 매 순간 나는 현재 위치를 확인하고, 현재 위치가 아니라 이미지가 도달하기를 원하는 위치의 결과를 보여줍니다. 이미지가 아직 그 위치에 도달하지 않은 경우에도 마찬가지입니다.
-(void)deductPlayerLife{
NSLog(@"x : %f",mosha1.frame.origin.x);
NSLog(@"y : %f",mosha1.frame.origin.y);
}
그래서, 매 초마다 이미지의 이동을 중지하지 않고 그 이미지의 실제 현재 위치를 어떻게 얻을 수 있습니다.