Hi, I used the following code to let players draw a line -but- it won’t work:
local lines = {}
local lineGroup = display.newGroup()
local prevX,prevY
local isDrawing = false
local i = 1
local function distanceBetween(x1, y1, x2, y2)
local dist\_x = x2 - x1
local dist\_y = y2 - y1
local distanceBetween = math.sqrt((dist\_x\*dist\_x) + (dist\_y\*dist\_y))
return distanceBetween
end
local function drawLine(e)
if(e.phase == "began") then
for i = #lines, 1, -1 do
if (lines[i]) then
lines[i].parent:remove(lines[i])
lines[i] = nil
end
end
lines = {}
line\_number = 1
prevX = e.x
prevY = e.y
isDrawing = true
elseif(e.phase == "moved") then
local distance = distanceBetween(prevX, prevY, e.x, e.y)
if(isDrawing and distance \< 50) then
if(lines[i]) then lineGroup:remove(i) end
lines[i] = display.newLine(prevX, prevY, e.x, e.y)
lines[i]:setColor(255, 255, 0)
lines[i].width = 2
lines[i].myName = "lines"
local dist\_x = e.x - prevX
local dist\_y = e.y - prevY
physics.addBody(lines[i], "static", { density = 1, friction = 0.5, bounce = -0.8, shape = {0, 0, dist\_x, dist\_y, 0, 0} } )
lineGroup:insert(lines[i])
end
elseif(e.phase == "ended") then
isDrawing = false
end
end
Runtime:addEventListener("touch",drawLine)
so how can I fix my problem?
Thanks 
[import]uid: 122056 topic_id: 34933 reply_id: 334933[/import]
and it is strange, even because if I use the director class instead of the storyboard, it works without any problems.