Overlapping animations help?

This is happening because you're adding a new batView each time a touch begins One way to fix this is to add the batView once, such as in a superview's or a view controller's init method. If you only want the batView to appear when a touch occurs, you can start it hidden via: during initialization batView. Dden = YES Since you're always doing the same animation each time, you might as well set up your animation parameters at the same time, instead of repeating that same set up with each touch: still during initialization NSArray* imageArray = /* set up your image array */; batView.

AnimationImages = imageArray; batView. AnimationDuration = 0.7 Now, when a touch occurs, you can handle it by starting the animation: Within touchesBegan: ... // Start the batView animation. BatView.

BatView isAnimating) batView startAnimating; // de the animation when it's done. Self performSelector:@selector(hideBat) withObject:nil afterDelay:0.71; } // Later: - (void) hideBat { batView. } You might want to do something different in hideBat if you don't always want it to disappear right after a single animation.

For example, if you want to always repeat an animation until the user stops clicking, you could set up an NSTimer object to go off as soon as there has been no user touches for at least 0.7 seconds. Each time the user touches the screen again, you can reset this timer Reference: UIImageView docs which includes brief descriptions of the animation methods.

This is happening because you're adding a new batView each time a touch begins. One way to fix this is to add the batView once, such as in a superview's or a view controller's init method. If you only want the batView to appear when a touch occurs, you can start it hidden via: // during initialization batView.

Since you're always doing the same animation each time, you might as well set up your animation parameters at the same time, instead of repeating that same set up with each touch: // still during initialization NSArray* imageArray = /* set up your image array */; batView. AnimationImages = imageArray; batView. AnimationDuration = 0.7; Now, when a touch occurs, you can handle it by starting the animation: // Within touchesBegan: ... // Start the batView animation.BatView.

BatView isAnimating) batView startAnimating; // de the animation when it's done. Self performSelector:@selector(hideBat) withObject:nil afterDelay:0.71; } // Later: - (void) hideBat { batView. } You might want to do something different in hideBat if you don't always want it to disappear right after a single animation.

For example, if you want to always repeat an animation until the user stops clicking, you could set up an NSTimer object to go off as soon as there has been no user touches for at least 0.7 seconds. Each time the user touches the screen again, you can reset this timer. Reference: UIImageView docs, which includes brief descriptions of the animation methods.

Here is my attempt at adding your code: (void)viewDidLoad { NSArray * imageArray = NSArray alloc initWithObjects: UIImage imageNamed:@"Bat1. Png", UIImage imageNamed:@"Bat2. Png", UIImage imageNamed:@"Bat3.

Png", UIImage imageNamed:@"Bat2. Png", UIImage imageNamed:@"Bat1. Png", UIImage imageNamed:@"Bat4.

Png", UIImage imageNamed:@"Bat5. Png", UIImage imageNamed:@"Bat6. Png", UIImage imageNamed:@"Bat5.

Png", UIImage imageNamed:@"Bat4. Png", nil; UIImageView * batView = UIImageView alloc initWithFrame: CGRectMake(0, 0, 80, 56); batView. AnimationImages = imageArray; batView.

AnimationDuration = 0.70; batView. BatView startAnimating; follower1 addSubview:batView; batView release; } (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UIImageView beginAnimations:@"follow" context:nil; UIImageView setAnimationDuration:1; UIImageView setAnimationBeginsFromCurrentState:YES; UITouch *touch = touches anyObject; follower1. Center = touch locationInView:self; UIImageView commitAnimations; UIImageView * batView; if (!batView isAnimating) batView startAnimating; batView.

// de the animation when it's done. Self performSelector:@selector(hideBat) withObject:nil afterDelay:0.71; } (void)hideBat { UIImageView * batView; batView. } (void)dealloc { super dealloc; } @end Thanks for your help so far Tyler!

My attempt at adding your code has produced an objc_msgSend crash. I have been stuck on this for 2 months, its really annoying me now. I have very limited free time and usually find something else to do but this is now the last piece of the jigsaw!

All I am trying to do is make a bat look like it flapping its wings while following your finger touches. Someone must have done this before? If I cant figure this out myself I will be giving credit to the person who does!

Its the least I could do!

One idea is to comment out the performSelector line to check if that is the culprit (that would be my first guess). – Tyler Sep 28 '09 at 15:43.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions