Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moomy

macrumors newbie
Original poster
Apr 28, 2010
28
0
Hi guys,

I have a simple UIImage animation, it works well but it can be called again mid animation, this runs the second go of animation over the first and looks a mess. I really want it so that it can only be called to animate again once it has finished animating. I'm guessing that I need to use the isAnimating BOOL but am not sure how to do this??

here is the code I have so far.

Code:
-(IBAction) aura{
	
	NSArray * auraArray = [[NSArray alloc] initWithObjects:
							
							// [UIImage imageNamed:@"smallblink.png"],
							[UIImage imageNamed:@"aura1.png"],
							
							[UIImage imageNamed:@"aura1-2.png"],
							[UIImage imageNamed:@"aura1-2-3.png"],
							[UIImage imageNamed:@"aura1-2-3-4.png"],
							[UIImage imageNamed:@"aura1-2-3-4-5.png"],
						   [UIImage imageNamed:@"evenmoreAura.png"],
						      [UIImage imageNamed:@"evenmoreAura.png"],
						   [UIImage imageNamed:@"evenmoreAura.png"],
						   [UIImage imageNamed:@"evenmoreAura.png"],

						   [UIImage imageNamed:@"aura1-2-3-4-5.png"],
						    [UIImage imageNamed:@"aura1-2-3-4.png"],
						    [UIImage imageNamed:@"aura1-2-3.png"],
						   	[UIImage imageNamed:@"aura1-2.png"],
							//[UIImage imageNamed:@"biggyshock.png"],
							
							nil];
	UIImageView * aura = [[UIImageView alloc] initWithFrame:CGRectMake(100, 40, 90, 20)];
	aura.animationImages = auraArray;
	aura.animationDuration = 1.30;
	aura.animationRepeatCount = 1;
	aura.contentMode = UIViewContentModeTop;
	[self.view addSubview:aura];
	[aura startAnimating];
	
	
	
	[aura release];
	[auraArray release];
	
	
	
}

I think this may be simple for an experienced programmer but as a noob I'm finding it a bit tricky.
thanks
moomy
 
Firstly, as presented, the code adds a new UIImageView to self every time the IBAction is triggered. Is that correct?

Secondly, what should happen if the IBAction is triggered during an animation? Nothing? Restart the animation? Or something else?

I'm guessing that I need to use the isAnimating BOOL but am not sure how to do this??

Are you familiar with the 'if' statement?
 
Hi there,

ideally I would like the button to do nothing if the animation is already running.

I guess I need a way to say, if animation is running do nothing else run animation.

if (isAnimating == YES)
{

return;
}
isAnimating = YES;

something like that??
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.