When a user clicks a button in my game to go to the levels it does the usual “push/press” effect. Recently I added some code to take the button out of focus if it gets dragged outside a certain boundary. It work fine other than the fact the button stays in the pressed/pushed phase. Heres my code:
[lua] local world3Btn
local function onworld3Touch ( event )
if event.phase == “began” then
display.getCurrentStage():setFocus( event.target )
event.target.isFocus = true
print(“touched”)
elseif event.target.isFocus then
if event.phase == “moved” then
local dx = math.abs( event.x - event.xStart )
local dy = math.abs( event.y - event.yStart )
if dx > 25 or dx < -35 then
event.phase = “cancelled”
print ( "id = " … event.x … ", phase = " … event.phase )
end
print( “Move Phase” )
print( “Move Ended” )
elseif event.phase == “ended” or event.phase == “cancelled” then
display.getCurrentStage():setFocus( nil )
event.target.isFocus = false
director:changeScene(“loadworld”)
print(“Moving on”)
end
end
end[/lua] [import]uid: 46082 topic_id: 34010 reply_id: 334010[/import]