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 Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-23-2009, 12:44 PM   #1 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 541
chaseacton is on a distinguished road
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default Making button activate timer countdown

Hello all, i am making a simple game where i need a button to activate a timer the counts down from 30 seconds, and then when it gets to 0 seconds, load another view. I have searched all day and found only bits and pieces of code that partially work, but nothing solid. Any code or sample projects would be appreciated.

Thanks, Chase

chaseacton@gmail.com
chaseacton is offline   Reply With Quote
Old 06-25-2009, 03:58 AM   #2 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 89
kalx is on a distinguished road
Default

Is there a particular part you're having trouble with? I split your problem up into the three obvious parts.

1. Creating a UIButton that calls a function to do something when pressed
2. Creating a timer (NSTimer) that counts down 30seconds
3. Switching to another view
kalx is offline   Reply With Quote
Old 06-28-2009, 04:00 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 56
natanavra is on a distinguished road
Default

Could be done simply:

- (void) or - (IBAction) type method {
[NSTimer sch....interval:30.0 delegate:self selector:@selector(changeAction) and so on];
}

- (void)changeAction {
[self.view addSubview:anotherView];
}
natanavra is offline   Reply With Quote
Old 06-28-2009, 04:03 PM   #4 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 541
chaseacton is on a distinguished road
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by natanavra View Post
Could be done simply:

- (void) or - (IBAction) type method {
[NSTimer sch....interval:30.0 delegate:self selector:@selector(changeAction) and so on];
}

- (void)changeAction {
[self.view addSubview:anotherView];
}
I figured it out, thanks though.
chaseacton is offline   Reply With Quote
Old 06-29-2009, 06:19 PM   #5 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 68
canit210 is on a distinguished road
Default

could you post the code that you got to work. I'm trying to do a similar thing.

Thanks.
canit210 is offline   Reply With Quote
Old 06-29-2009, 06:32 PM   #6 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 541
chaseacton is on a distinguished road
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by canit210 View Post
could you post the code that you got to work. I'm trying to do a similar thing.

Thanks.
I followed this tutorial which worked amazingly:

Welcome to the iPhone Development Central Website!
chaseacton is offline   Reply With Quote
Reply

Bookmarks

Tags
clock, game, nstimer, timer

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: 406
7 members and 399 guests
13dario13, ChrisYates, fredidf, iOS.Lover, Leslie80, Wikiboo, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K
Powered by vBadvanced CMPS v3.1.0

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