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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-02-2011, 09:53 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default Why does my timer codes not work

Hi, i have a game (the reason i'm not posting in the game forum is because this is strictly related to timers). I want different timers to go off, more than once. And it seems like only one goes off at a time, here is a codes snippet:

Code:
- (void) blink {
	if (score < 6) {
		Bblink2 = TRUE;
		blink2T = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector (blink2) userInfo:nil repeats:YES];
	} else if (score > 5 && score < 75) {
		[blink2T invalidate];
		blink2T = nil;
	}
	if (score > 74 && score < 81) {
		Bblink3 = TRUE;
		blink3T = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector (blink2) userInfo:nil repeats:YES];
		Bblink2 = TRUE;
		blink2T = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector (blink2) userInfo:nil repeats:YES];
	} else if(score > 80 && score < 400) {
		[blink3T invalidate];
		blink3T = nil;
		[blink2T invalidate];
		blink2T = nil;
	}
	if (score > 399 && score < 406) {
		Bblink4 = TRUE;
		blink4T = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector (blink2) userInfo:nil repeats:YES];
		Bblink3 = TRUE;
		blink3T = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector (blink2) userInfo:nil repeats:YES];
		Bblink2 = TRUE;
		blink2T = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector (blink2) userInfo:nil repeats:YES];
		
	} else if(score > 405) {
		[blink4T invalidate];
		blink4T = nil;
		[blink3T invalidate];
		blink3T = nil;
		[blink2T invalidate];
		blink2T = nil;
	}
}
My theory is that it is not being called when the score is higher than 5. I can't call it in a timer, because that is stupid. If the reason that this code is not working is because it is not being called enough. I can fix that on my own, i just need a second opinion, before i go changing my code
sumosumo84 is offline   Reply With Quote
Old 02-03-2011, 12:02 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 99
Mizonnz is on a distinguished road
Default

Maybe stick some NSLog statements in to see when various bits of code are being executed.

Also, it seems odd to me that you're making several timers at once that fire the same selector, so eg. for a score of 78 you'll be calling blink2 twice every 0.1 seconds.
Mizonnz is offline   Reply With Quote
Old 02-03-2011, 04:57 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

ohhhhhhhhhhhh wowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwww. Thanks for pointing out that i had blink2 for all the selectors, you see. I just copy and pasted that line and, well. You know
sumosumo84 is offline   Reply With Quote
Reply

Bookmarks

Tags
error, game, timers

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: 370
14 members and 356 guests
7twenty7, blasterbr, Clouds, dre, EvilElf, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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