Is it possible to draw a line in Corona? [import]uid: 3018 topic_id: 177 reply_id: 300177[/import]
By drawing a rect with a width of 1 pixel, you would be drawing a line. You cant say, here’s cord. A and cord. B and tell it to connect the dots, you have to draw the box and give it a rotation (asusming A and B aren’t on the same axis).
Do you have a code snippet of how you would want that to work? Its possible we may be able to add it somewhere down the road. [import]uid: 5 topic_id: 177 reply_id: 167[/import]
Hi, thanks for the reply. I found the Rect command but don’t think it will work for what I want to do.
I’d like to be able to draw a line following the users finger
Something similar to :
’ lineTo(_xmouse, _ymouse) ’ in flash would be great.
or basically the ability to draw a line from point x to point y. Also found this: http://wiki.ps2dev.org/psp:lua_player:tutorial
would be nice to be able to do similar in Corona.
Thanks [import]uid: 3018 topic_id: 177 reply_id: 169[/import]
I will file a feature request for a simpler method, but I think its technically possible. You can extract coordinates from touch events and then have it draw/rotate based on those coordinates. Here’s a simple coordinate finding method:
[code]
local t = display.newText( “Click the screen”, 0, 0, nil, 12 )
t:setTextColor( 255, 255, 136, 255 )
[code]
local screenBounds = display.newRect( 0,0,320,480 )
screenBounds:setFillColor(255,255,255)
[code]
local function printEvent( event )
local label = event.name
if event.phase then
label = label … “.” … event.phase;
end
print( “event(” … label … “) hit(”…event.x…","…event.y…")" )
end
[code]
function screenBounds:touch(event)
local count = event.count
printEvent (event)
local phase = event.phase
return true
end
screenBounds:addEventListener( "touch",screenBounds)
You could then store the coordinates in an array and do something like:
[code]
local cords = somearrayvalue
line.x = cords
etc. That should point you in the right direction I believe. I will investigate further and see if I can’t get you some more code. [import]uid: 5 topic_id: 177 reply_id: 172[/import]
Thanks for that perfect for what I’m doing. Also would be nice to be able to fill as in flash x.beginFill x.endFill to achieve a polygon with fill color.
[import]uid: 3018 topic_id: 177 reply_id: 181[/import]