Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-04-2011, 12:18 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 551
aldcorn@live.com is on a distinguished road
Default animate each object in an array one after the other with a slight delay.

Hi guys,
I was hoping to find a way to animate each object of an array of uiviews one after another like the crowd doing the wave at a stadium.

My array is set up and I am currently able to get one or all of the objects to animate but I have no idea how to get the object a index 0 to jump, and then the object at index 1 to jump, and so on with a slight delay after each one.


This is the code I currently have that allows me to have one object from the array pulse based on the object at index helloInt. I have tried various ++ ideas but unfortunately for me I am not very proficient in object c and my google searches have not given me what I want (probably don't know what I am searching for I guess)
Code:
- (void) pulse {
		currentView.transform = CGAffineTransformMakeScale(0.6, 0.6);
		[UIView beginAnimations:nil context:nil];
		[UIView setAnimationDuration:0.2];
		[UIView setAnimationDelegate:self];
		currentView.transform = CGAffineTransformMakeScale(0.5, 0.5);
		currentView.transform = CGAffineTransformMakeScale(1.3, 1.3);
		currentView.transform = CGAffineTransformMakeScale(1.0, 1.0);
		[UIView commitAnimations];
	UIButton *popButton = [arrayPlayer1btns objectAtIndex:helloInt];
	currentView = popButton;
	popButton.highlighted = YES;
		}

Here is some code I use with the array I am talking about. Here I am hiding certain objects in the array based on whether they are above or below a certain int.
Code:
-(IBAction)hideMyButtons:(id)sender {
	NSLog(@"hideMyButtons Array is: %@",arrayPlayer1btns);

	for (int i=0; i< [arrayPlayer1btns count]; i++){
			UIButton *button = [arrayPlayer1btns objectAtIndex:i];
			BOOL shouldHide = (i>(addThisToA + previousScoreA));
			NSLog(@"button:%x shouldHide:%d",button, shouldHide);
			button.hidden=shouldHide;
			currentView = button;

	}
EDIT:
i don't need help with the animation aspect, more specifically I would like help with iteration through the array I guess.

Hopefully I explained my question clearly. If anyone out there has the time any help would be appreciated.

Thanks,
Rob

Last edited by aldcorn@live.com; 03-04-2011 at 01:44 PM.
aldcorn@live.com is offline   Reply With Quote
Old 03-06-2011, 01:24 AM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 551
aldcorn@live.com is on a distinguished road
Default maybe this is a more clear description

I wonder if this code will help explain what I am trying to achieve.
Code:
- (void) pulseCelebrate {
	for (int i=0; i< [arrayPlayer1btns count]; i++){
		UIButton *buttonCelebrate = [arrayPlayer1btns objectAtIndex:i];

//if I use the following every other item pulses
//UIButton *buttonCelebrate = [arrayPlayer1btns objectAtIndex:i++];
		
        currentView = buttonCelebrate;
	currentView.transform = CGAffineTransformMakeScale(0.6, 0.6);
	[UIView beginAnimations:nil context:nil];
	[UIView setAnimationDuration:0.2];
	[UIView setAnimationRepeatCount:1e100f];
	[UIView setAnimationDelegate:self];
	currentView.transform = CGAffineTransformMakeScale(0.5, 0.5);
	currentView.transform = CGAffineTransformMakeScale(1.3, 1.3);
	currentView.transform = CGAffineTransformMakeScale(1.0, 1.0);
	[UIView commitAnimations];
	}}
What this code does: It repeatedly scales my array of uibuttons once they are set as the currentView in a pulsing manner. This code pulses all 100 of my array objects at once. I would somehow like to have the objects animate this way but I would ALSO like to have them start at slightly incremented times. I guess even random times would be ok if that is easier.

Am I looking at using an NSTimer or am I trying to do something that I shouldn't do?

Thanks for taking the time to look at this,

Rob
aldcorn@live.com is offline   Reply With Quote
Old 03-06-2011, 09:11 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 4
cwalcott is on a distinguished road
Default

I think you can use the setAnimationDelay: method to set a delay before the animation begins.

So maybe you could add a line like:

Code:
[UIView setAnimationDelay:(i * 0.1)];
to add a 100 ms delay between the beginning of each animation.

Last edited by cwalcott; 03-06-2011 at 09:13 PM.
cwalcott is offline   Reply With Quote
Old 03-07-2011, 01:10 AM   #4 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 551
aldcorn@live.com is on a distinguished road
Default oh yeah!

Thanks very much. I was hoping it was going to be one line of code!

I appreciate your help. Here is my current code for animating an array of uibuttons that are then set as the current view and animated. There are two animations going here and I am going to tweak them for my purposes but thanks for helping me out.

Cheers,
Rob
Code:
- (void) pulseCelebrate {
	for (int i=0; i< [arrayPlayer1btns count]; i++){
		UIButton *buttonCelebrate = [arrayPlayer1btns objectAtIndex:i++];
		currentView = buttonCelebrate;
		currentView.transform = CGAffineTransformMakeScale(0.6, 0.6);
		[UIView beginAnimations:nil context:nil];
		[UIView setAnimationDelay:(i * 0.1)];
		[UIView setAnimationDuration:0.2];
		[UIView setAnimationRepeatCount:8];
		[UIView setAnimationDelegate:self];
		currentView.transform = CGAffineTransformMakeScale(0.5, 0.5);
		currentView.transform = CGAffineTransformMakeScale(1.3, 1.3);
		currentView.transform = CGAffineTransformMakeScale(1.0, 1.0);
		[UIView commitAnimations];
	}}
aldcorn@live.com is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 485
16 members and 469 guests
7twenty7, AlanFloyd, AppsBlogger, David-T, iAppDeveloper, imac74, Jaxen66, lovoyl, Music Man, mutantskin, Paul Slocum, Sami Gh, SLIC, solardrift, unicornleo, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,683
Threads: 94,131
Posts: 402,932
Top Poster: BrianSlick (7,990)
Welcome to our newest member, unicornleo
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:13 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0