displayLine.append doesn't work realtime (unless line.width is set to eg line.width+0.0000001)

i've got a function to draw a poly line with the mouse (i was trying to add it to Martian Control). but the polyLine doesnt render immediately during drawing, unless i had a minute amount of width eg tempLine.width=tempLine.width+0.000001

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local tempLine 
local function runTouch(event)
 
        if(event.phase=="began") then
                
                if(tempLine==nil) then 
                        print("add new line")
                        tempLine=display.newLine(event.x, event.y, event.x, event.y)
                        tempLine:setColor(255,0,0,255)
                        tempLine.width=3
                end
 
        elseif(event.phase=="moved") then
        
                print("moved to "..event.x..","..event.y)
                tempLine:append(event.x,event.y)
 
                -- TAKE THIS OUT AND IMMEDIATE DRAWING FAILS
                tempLine.width=tempLine.width+0.000001
                
        elseif(event.phase=="ended") then
                print("line added")
                tempLine.parent.remove(tempLine)
                tempLine=nil
        end
 
end
 
Runtime:addEventListener("touch", runTouch)

actually sorry the subject is wrong.. the smallest number i can add to force render is 0.000001 as per the code

trust me when i tell you that's not going to work

try this instead

http://developer.anscamobile.com/assets/main.lua.zip

if you can do a video to show our members that would be great.

carlos

Is this really the most efficient way to draw a line from a user's touch? Seems like not only way to many points but the worse seems to be the redrawing the line every move just feels wrong. If I did this using just by creating a circle with each touch I can simulate a line on the screen without having to redraw each circle.

Why is append not real time?

If you have the line and it has already been drawn why can't we just keep adding new points that it continues to connect to for us without the developer having to write so much logic. Seem like something a simple a drawing a line with your finger would be so complex when so many other things have been simplified with this SDK.

This still doesn't work btw. If you try to draw the line fast then it just freezes and you can no longer draw anything.

Is there not a simplified way to do line drawing and turn the line into a physics object yet?

views:1489 update:2011/11/28 11:38:31
corona forums © 2003-2011