Maybe something like this? The user drags the yellow square over the red to follow its path.
[code]
local abs = math.abs
local star1 = display.newRect( 320,250,50,300)
local star2 = display.newRect( 320,200, 400,50)
local touchpad = display.newRect(320,550,50,50)
touchpad:setFillColor(255,0,0)
local touchpad2 = display.newRect(320,550,50,50)
touchpad2:setFillColor(255,255,0)
local function padmovesecond()
local padmove2 = transition.to( touchpad, {time=4000, alpha=1, x=touchpad.x+350, y=touchpad.y } )
end
local padmove = transition.to( touchpad, {time=4000, alpha=1, x=touchpad.x, y=touchpad.y-350, onComplete=padmovesecond } )
function touchListener4 (touch)
local phase = touch.phase
if (phase == “moved”) then
–print(“touch”)
touchpad2.x = touch.x
touchpad2.y = touch.y
elseif (phase == “ended”) or (phase == “cancelled”) then
print(“end”)
end
end
touchpad2:addEventListener(“touch”, touchListener4)
local function listener(event)
if abs(touchpad.x - touchpad2.x) > 25 or abs(touchpad.y - touchpad2.y) > 25 then
print(“bad”)
else
print(“good”)
end
end
Runtime:addEventListener(“enterFrame”, listener)
[/code] [import]uid: 10903 topic_id: 7222 reply_id: 25639[/import]