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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 11-03-2009, 02:44 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 9
Question Conflicting Timers?

Hi All,

I am just looking into creating a game that uses the accelerometer to move a ball around a screen and have noticed that the accelerometer:didAccelerate method requires a time interval for when to be called. Jeff LaMarche's book 'Beginning iPhone Development' uses this timer to update his Ball by setting the Ball classes UIAcceleration object and then calling it's draw method - sounds simple enough so far.

However, I already have an animationTimer set up for my main game loop which calls my update scene method, which updates the game logic, followed by my render scene method, which draws the new scene to the screen.

I am now struggling to see the need for the animationTimer as I could use the accelerometer's timer to call the updateScene() method instead and therefore I would not have two conflicting timers calling code at different times. Does anybody have any advice on whether the animationTimer is still needed or whether you believe I am going about this the wrong way as I'm still unsure on how these two timers work fully.

Thanks

BebopSong
BebopSong is offline   Reply With Quote
Old 02-22-2010, 10:06 AM   #2 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,178
Default

Quote:
Originally Posted by AaronTassle View Post
What's up everyone? My name is Aaron. I'm from Portland. I'm new to the forum and just wanted to say hi.. I hope I posted this in the right section.
Why would you think that posting a random "What's up guys?" message in someone else's thread with the title "Conflicting Timers?" would be "in the right section"?
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 02-22-2010, 12:33 PM   #3 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

You can have as many timers as you want going.

It's limited though by the device.
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 02-25-2010, 01:07 AM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

When you say "accelerometer:didAccelerate method requires a time interval for when to be called" you mean accelerometer.updateInterval, right? That's just an indication of how often you'd like didAccelerate: to be called. You do not always get the interval you ask for. You also say "Jeff LaMarche [...] uses this timer to update his Ball" -- do you mean there's an NSTimer there too, or do you mean he does that from didAccelerate: ?

You're right, you probably only need one timer to call your updateScene method, and using one timer will probably be less confusing. I would use didAccelerate: to set your input values, but do the actual movement with your timer.

More timers = more stuff to pause/resume when the game is interrupted, possible problems when the timers are triggered in a different order, and more code in general.
__________________

Free Games!
smasher is offline   Reply With Quote
Reply

Bookmarks

Tags
accelerometer, animation, 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: 248
13 members and 235 guests
2WeeksToGo, ADY, BrianSlick, Dani77, Dattee, headkaze, kapps11, mer10, mgon987, sneaky, timle8n1, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,879
Threads: 89,228
Posts: 380,744
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mgon987
Powered by vBadvanced CMPS v3.1.0

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