try this … this is better. this should get you started.
[code]
local linePoints = {};
local gRC; – = display.newGroup();
local FALSE = 0
local TRUE = 1
local moved = FALSE;
local bbg = display.newRect(0,0,display.contentWidth,display.contentHeight);
bbg:setFillColor(55,55,55)
local draw;
–
– drawline
local function drawLine()
if ( moved == FALSE ) then return; end
if ( line ) then line:removeSelf() end
if #linePoints > 2 then
line = display.newLine(linePoints[1].x,linePoints[1].y,linePoints[2].x,linePoints[2].y);
for i = 3, #linePoints, 1 do
line:append(linePoints[i].x,linePoints[i].y);
end
line:setColor(255,255,0);
line.width=12
end
end
local function dragHandles(event)
local phase = event.phase
if “began” == phase then
– Make target the top-most object
local pt = {}
pt.x = event.x;
pt.y = event.y;
table.insert(linePoints,pt);
elseif “moved” == phase then
local pt = {}
pt.x = event.x;
pt.y = event.y;
table.insert(linePoints,pt);
moved = TRUE;
elseif “ended” == phase or “cancelled” == phase then
moved = FALSE;
drawLine(linePoints,40);
end
return true
end
–
local function draw (event )
if ( moved == TRUE ) then
drawLine()
return true;
end
end
–
local function main()
Runtime:addEventListener(“touch”,dragHandles);
Runtime:addEventListener(“enterFrame”,draw);
end
–
main();
[/code] [import]uid: 24 topic_id: 9530 reply_id: 34889[/import]