I am currently using the trial sdk on windows to write an app for android and am having trouble with the mutlitouch. I believe I have found a significant bug, however it could simply be misuse the functionality.
In a nutshell, if a touch event moves outside the bounds of an object, the system will stop sending touch events to that object. The easiest way to demonstrate this is to add code to the example DragMeMultitouch:
Here is the modified onTouch function:
[lua]local function onTouch( event )
local t = event.target
– Print info about the event. For actual production code, you should
– not call this function because it wastes CPU resources.
printTouch(event)
local phase = event.phase
if “began” == phase then
– Make target the top-most object
local parent = t.parent
parent:insert( t )
display.getCurrentStage():setFocus( t, event.id )
– Spurious events can be sent to the target, e.g. the user presses
– elsewhere on the screen and then moves the finger over the target.
– To prevent this, we add this flag. Only when it’s true will “move”
– events be sent to the target.
t.isFocus = true
– Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
t.alpha = 0.5
elseif t.isFocus then
if “moved” == phase then
– Make object move (we subtract t.x0,t.y0 so that moves are
– relative to initial grab point, rather than object “snapping”).
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( t, nil )
t.isFocus = false
t.alpha = 1
end
end
– Important to return true. This tells the system that the event
– should not be propagated to listeners of any objects underneath.
return true
end[/lua]
When the boxes are touched for the first time, they turn transparent. When they are released, they become opaque again.
The problem occurs when I drag my finger fast enough that it exits out of the box’s touch box. In the example above, the box will remain transparent because its ended/cancelled event does not get called.
Is anyone else having this problem? And could someone try this on a different model phone, as it may only be the Droidx that has this issue.
Thanks in advance,
-Jake [import]uid: 42133 topic_id: 8053 reply_id: 308053[/import]