Guys,
I am trying to use multi touch for the first time.
I did a simple app, with two buttons… its supposed to print the words “Touch Began” and “Touch ended” depending on the phase…
each button works fine seperately… but when I hold one down, while click on the other… sometimes I am missing the Began or ended… what am I missing…
I have included the code below
[code]
system.activate( “multitouch” )
local myText = display.newText(“Test”, 100, 100, native.systemFont, 12)
myText:setTextColor(255, 255, 255)
local function Touch1 (e)
local t = e.target
if (e.phase ==“began”) then
myText.text = myText.text … “\nTouch 1 Began”
display.getCurrentStage():setFocus( t, e.id )
elseif (e.phase ==“ended”) then
myText.text = myText.text … “\nTouch 1 Ended”
display.getCurrentStage():setFocus( t, nil )
end
end
local function Touch2 (e)
local t = e.target
if (e.phase ==“began”) then
myText.text = myText.text … “\nTouch 2 Began”
display.getCurrentStage():setFocus( t, e.id )
elseif (e.phase ==“ended”) then
myText.text = myText.text … “\nTouch 2 Ended”
display.getCurrentStage():setFocus( t, nil )
end
end
local myCircleRight = display.newCircle( 200, 250, 20 )
myCircleRight:setFillColor(128,128,128)
myCircleRight:addEventListener(“touch”, Touch1)
local myCircleLeft = display.newCircle( 50, 250, 20 )
myCircleLeft:setFillColor(128,128,128)
myCircleLeft:addEventListener(“touch”, Touch2)
[/code] [import]uid: 67619 topic_id: 25781 reply_id: 325781[/import]