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.
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"?
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.