Line Drawing question

Hi All,

Sorry, I’m new to Corona and couldn’t find any help with a line drawing code so have tried myself to use the the phase event to draw a line. Just to clarify, I’m trying to draw a line by moving my finger across the screen. The code below does actually draw a line where my finger has been but the line doesn’t display until I touch the screen again after I’ve finished moving my finger. Therefore the line isn’t being displayed in realtime as I move my finger, I just tap the screen after and then it draws it.

Can anybody help so that the line updates in realtime as my finger is moving?

Many thanks,

Ben

local function spawnPic( event )
local phase = event.phase

if “began” == phase then
board = display.newLine(event.x,event.y,event.x,event.y)
board:setColor(0,0,0,255)
board.width = 5
print (“X/Y Position:”, x_position, y_position, event.x, event.y)
end

if “moved” == phase then
board:append(event.x, event.y)
end

end [import]uid: 13974 topic_id: 7206 reply_id: 307206[/import]

you should redraw the line each frame. store the points in an array if you are using more than 2 points

Carlos posted an example at the bottom of here
http://developer.anscamobile.com/forum/2010/12/15/displaylineappend-doesnt-work-realtime-unless-linewidth-set-eg-linewidth00000001

[import]uid: 6645 topic_id: 7206 reply_id: 25349[/import]