Touches: Device vs Simulator - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Touches: Device vs Simulator (/thread-734.html)
Touches: Device vs Simulator - vectorscope - Sep 22, 2009 01:53 PM
I have been working on game for a few weeks now, exclusively through the simulator which was working beautifully.
I finally got a developer account setup so I could test on an actual device and...eeep...I am finding the way touches are registered completely suck.
I am listening for the start of the touch, moving and end touch to move my character. As I said this works fine in the simulator but on the device it is very choppy and unresponsive.
Here is how I'm handling each event:
Then in my player class I do the following:
Any idea why things are so different in the sim vs the device?
Or how I can improve this so movement of the player on the phone is smooth (usable for that matter).
Thank you for your time and attention.
Touches: Device vs Simulator - longjumper - Sep 22, 2009 02:38 PM
I'm not familiar with touchesBegan:withEvent:view: or touchMoved:withEvent:view:. These methods are not documented.
The methods you should be overriding in your UIResponder subclass are touchesBegan:withEvent:, touchesMoved:withEvent: and touchesEnded:withEvent:.
Besides that, you are doing work that has already been done for you. You can send the message timestamp to a UITouch and it will return you the number of seconds since system startup, which is not only less work than creating a NSDate and computing the time interval since the epoch, but your deltas will be more precise.
Also, why are you asking the event for all of its touches and then pulling any object from it? Send anyObject to the touches NSSet sent to you in that method.
Those wouldn't cause much of a speed problem, but they are things you should probably know. I don't know why your touch events are sluggish. I don't even see how your methods are being called, but there could be some undocumented API you are using. The touchesMoved method you have should never be called, as it doesn't match at all (touchMoved should be touchesMoved).
Touches: Device vs Simulator - vectorscope - Sep 22, 2009 03:08 PM
Thanks long jumper...yes actually these are my own handlers...
The touches are first captured in my view class:
And as you can see are forwarded onto my game class:
From there depending on the current state of the game they are forwarded again to the appropriate handlers...a couple of which I have posted above.
So that is how the original methods I posted are called. Make sense?
Touches: Device vs Simulator - vectorscope - Sep 22, 2009 03:19 PM
oh so I should just do...
last.time = [touch timestamp];
Touches: Device vs Simulator - Skorche - Sep 22, 2009 03:25 PM
Not sure what the specific problem is here, but there are a ton of subtle differences/bugs between the actual device and the simulator. From now on, you really are going to want to test early and often on the real device.