i have 2 circles on screen and i want to draw a line between them (just between these circles)
how to detect that where the ended phase happend??
local function touched(event)
if event.phase == “began” then
print(event.target.id)
display.getCurrentStage():setFocus( event.target )
event.target.isFocus = true
elseif event.phase == “ended” or event.phase == “cancelled” then
display.getCurrentStage():setFocus( nil)
event.target.isFocus = false
– ====================
– where is it happenning?? is it happening on a circle?? or its “ended” on a bg object?
--===========
local L = display.newLine( event.xStart, event.yStart, event.x, event.y )
L.strokeWidth = 2
L:setStrokeColor( 0, 0 ,256 )
print(event.target.id)
end
return true
end
local bg = display.newRect(centerX,centerY,screenWidth,screenHeight)
local a = display.newRect( 100, 100, 50, 50 )
a:setFillColor ( 255, 0, 0)
a.id=1
a:addEventListener ( “touch”, touched )
b= display.newRect( 300, 300, 50, 50 )
b:setFillColor ( 0, 255, 0)
b.id=2
b:addEventListener ( “touch”, touched )