views:

62

answers:

2

ok, so apparently xna games can only run at 30fps, which is a shame, because our game on iphone looked alot better at 60...

at any rate, because the only way you can get information about the touch screen state is to get its current state, effectively this means you can only sample the touch screen at 30 fps.

even if our game has to run at 30fps, is there any way to get higher resolution sampling from the touch screen? maybe through callbacks? or by accessing a list of touch events with time stamps?

A: 

The sampling rate of 30fps is set for performance reasons.

Even if you could find a way to query for touches more frequently you still couldn't update the UI at a faster rate so I'm not sure what benefit you'd get.

Before spending too much time on trying to find a solution I'd test on an actual device to see how acceptable 30fps really is.

Matt Lacey
oh, we have, and the problem is we have like a trail that follows the touch around. and its all bumpy at 30fps, we have smoothed it out with splines for the time being, but it still seems a bit odd that you can't do it... you can do it on the iphone 3G... and I have cooking appliances that are more computationally powerful than that... hell... even the DS...
matt
You have to remember that the Windows OS won't always be running on the same hardware like iPhone - there will be different capabilities available. There is also battery life to consider.
Crappy Coding Guy
+1  A: 

The function you are looking for is TouchPanel.GetState. It is a simple matter of calling this function at 60Hz.

To get 60Hz you could set Game.TargetElapsedTime to 1/60th of a second. This will give you two updates to every one draw (according to Shawn Hargreaves' post here) assuming you are VSyncing at 30FPS.

If you still want your game state updates to run at 30FPS (just doing touch input at 60FPS), then you could put those updates on a different thread. Start an update going on that thread on the first call to Game.Update, and wait for it to finish on the second one, and so on.

(You should note that normally XNA input must be done on the main thread (source). I assume this applies to Phone and to touch input.)

Alternately you could replace the Game class's timing yourself entirely (calling GraphicsDevice.Present yourself). It's not easy to do, but it's possible. A good place to start is to look at the Game class in Reflector.

(Disclaimer: I haven't tried any actual Phone-based development yet, so there may be some Phone-related gotchas I am unaware of.)

Andrew Russell