My game requires the user to draw lines with their fingers. In the instructions I want an image of a finger drawing the line.
This is the finger moving function:
[lua]
local function touchMove()
local touchme= display.newImageRect(‘finger.png’,30 ,38)
touchme.x = 25
touchme.y = 120
group:insert(touchme)
transition.to(touchme,{ time = 10000, x= w-45, y= h+20})
--transition=easing.inOutQuad
end
touchMove()
The function that allows the user to draw a line with there finger is as follows:
[lua]
function runTouch(e)
if e.phase == “began” then
prev_x = e.x
prev_y = e.y
elseif e.phase == “moved” then
lines[line_number] = display.newLine(prev_x, prev_y, e.x, e.y)
lines[line_number]:setColor(math.random(255), math.random(255), math.random(255))
lines[line_number].width = line_width
group:insert(lines[line_number])
dist_x = e.x - prev_x
dist_y = e.y - prev_y
– Add a physics body that’s a flat polygon that follows each segment of the line
physics.addBody(lines[line_number], “static”, { density = 1, friction = 1, bounce = .1, shape = {0, 0, dist_x, dist_y, 0, 0} } )
prev_x = e.x
prev_y = e.y
line_number = line_number + 1
elseif e.phase == “ended” then
end
end
Runtime:addEventListener(“touch”, runTouch)
So I want to combine these 2 functions so it appears the finger in transition is drawing the line. Any help will be much appreciated!
