Hello,
I have a few draggable objects in my project. I would like to run a different command (for example, play an animation after user drag object 1, play a sound after user drag object 2, etc) after user drag an object.
Is there a way to attach an “onComplete” kind of function in the event listener? For example:
witch:addEventListener("touch", onDrag, {onComplete = "doIt()"} )
If not, how could I set the “IFs” inside the drag function below:
local function onDrag( event )
local t = event.target
print(t)
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 )
t.isFocus = true
-- Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
elseif t.isFocus then
if "moved" == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif "ended" == phase or "cancelled" == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
--act\_action\_896()
end
end
return true
end
Thanks a lot,
Alex [import]uid: 4883 topic_id: 13049 reply_id: 313049[/import]
