Hello . I have some UIImageViews and when the user is touching, an animation with a certain duration starts. A trigger counts ++ and with the next touch another animation starts to play. But if the user touches to fast or make a doubletouch the first animation does not finish until the last frame. I tried the "sleep()" command, but it does not work.
#pragma mark HenneAnimation
if([touch view] == ani_Henne){
//trigger strats with zero
switch (trigHenne) {
case 0:
//firstanimation 1 sec
ani_Henne.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"ani_Henne01.png"],
[UIImage imageNamed:@"ani_Henne01.png"],
[UIImage imageNamed:@"ani_Henne02.png"],
[UIImage imageNamed:@"ani_Henne01.png"],
[UIImage imageNamed:@"ani_Henne01.png"],nil];
ani_Henne.animationDuration = 1;
ani_Henne.animationRepeatCount = 1;
[ani_Henne startAnimating];
[self.view addSubview:ani_Henne];
trigHenne++;
break;
case 1:
//second animation 1 sec
ani_Henne.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"ani_Henne03.png"],
[UIImage imageNamed:@"ani_Henne05.png"],
[UIImage imageNamed:@"ani_Henne03.png"],
[UIImage imageNamed:@"ani_Henne03.png"],
[UIImage imageNamed:@"ani_Henne04.png"],
[UIImage imageNamed:@"ani_Henne05.png"],
[UIImage imageNamed:@"ani_Henne03.png"],nil];
ani_Henne.animationDuration = 3;
ani_Henne.animationRepeatCount = 1;
[ani_Henne startAnimating];
[self.view addSubview:ani_Henne];
trigHenne++;
break;
case 2:
[self.view bringSubviewToFront:ani_Henne];
ani_Henne.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"ani_Henne06.png"],
[UIImage imageNamed:@"ani_Henne07.png"],
[UIImage imageNamed:@"ani_Henne06.png"],
[UIImage imageNamed:@"ani_Henne06.png"],
[UIImage imageNamed:@"ani_Henne08.png"],
[UIImage imageNamed:@"ani_Henne08.png"],
[UIImage imageNamed:@"ani_Henne09.png"],
[UIImage imageNamed:@"ani_Henne08.png"],
[UIImage imageNamed:@"ani_Henne09.png"],
[UIImage imageNamed:@"ani_Henne08.png"],
[UIImage imageNamed:@"ani_Henne07.png"],
[UIImage imageNamed:@"ani_Henne08.png"],
[UIImage imageNamed:@"ani_Henne09.png"],
[UIImage imageNamed:@"ani_Henne08.png"],nil];
ani_Henne.animationDuration = 2.75;
ani_Henne.animationRepeatCount = 1;
[ani_Henne startAnimating];
[self.view addSubview:ani_Henne];
trigHenne++;
break;
case 3:
trigHenne=0;
// etc. animations
break;
default:
break;
}
}