What priority does the touch event have over enterFrame?

So I have this game running on my iPhone 3g, and I am trying to squish a laggy touch problem.

Essentially, I am running at 60fps, I have the standard enterFrame that loops over my main game loop, I have a touch event on a full screen newRect to capture touches anywhere on the screen. I have the rect as the stage:setFocus(TOUCH_AREA) setup as well, and the function to capture touches returns true, so that corona does not try to ‘bubble’ the touch event up or down.

My problem is that, about 50% of the time, the touch event seems not to fire until 3 frames after I touched the screen. Other times, it works fine and I animate accordingly.

I will have to do some testing when I get home, but I am curious about how the touch event fires.

  1. Does the touch event fire before, or after, the enterFrame event? Essentially, which has priority?

  2. Does it actually try to fire IN an enterFrame event? As in, while executing my enterFrame code, the touch event is an interrupt of the code in the enterFrame, and it executes before the code in the enterFrame event finishes?

  3. Is 60fps on an iPhone 3g too fast for the touch events to be captured?

Ill probably have to test with the functions to get the current time on the device to get exactly when events are called, but if someone has some insight, I would appreciate it!

[import]uid: 8541 topic_id: 2696 reply_id: 302696[/import]

Hi,

I can’t tell you exactly how it works as I didn’t code the engine but here some thoughts of mine.

About the rectangle you use to get a general touch event. I would use a touch eventlistener of the runtime. This way you can also get the coordinates of your touch and no object is bothered.

[lua]–****************************************************************
– Touch handler function
local onTouch = function( event )
–****************************************************************
if event.phase == “began” then
myTouchX = event.x
myTouchY = event.y
end
–return true
end

Runtime:addEventListener( “touch”, onTouch )[/lua]

About that the touches sometimes are laggy. Could it be, that there are other objects between your rectangle and your touch at these moments? That could be a reason why the touches are not registered as these objects would block them. Or is your rectangle the most top drawn one. I never used your method but i think that it could be the fact.

Anyway, your idea about using functions and print the time is a good one. Do that and you will figure out when a touch event is happening.

Cheers
Michael Hartlef

http://www.whiteskygames.com
http://www.twitter.com/mhartlef
[import]uid: 5712 topic_id: 2696 reply_id: 8041[/import]