hand drawings to physics

I read the tutorial http://developer.coronalabs.com/code/gerald-anderson, which create multiple objects, and AddBody, but it’s not like “dynamic” in a single object. As example: http://www.youtube.com/watch?v=h_meXQyPHmw. Help me. thank you

You haven’t actually asked a question. Just saying “help me” will not draw much support. You have not even said anything about your problem or your code.

excuse is that I used a translator.

Just want to add a physical dynamic type for a drawing done by hand

physics.addBody( <body>, “dynamic”, { <properties> } )

What’s your first/natural language?

Can you post your code?

My first language is portuguese.

Code:

local function draw_line(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(255,0,0);–math.random(255), math.random(255), math.random(255))

    lines[line_number].width = line_width

    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 = 0.5, bounce = 0, shape = {0, 0, dist_x, dist_y, 0, 0} } )

    prev_x = e.x

    prev_y = e.y

    line_number = line_number + 1

    print (line_number);

  elseif e.phase == “ended” then

  end

end

create various objects, wanted to create a single (one) object? 

as in the example Video…

You are not adding your line objects to a display group. Do that (look at the newLine documentation) at then apply the physics body to the display group.

I don’t know what lines[] is, but I think it is a table, not a display group. All you are doing is storing a list of lines, not a display group to control them.

Btw, when posting more than one line of code, use the   <>  button to show the code with line numbers.

ok, horacebury. Thank you.

You haven’t actually asked a question. Just saying “help me” will not draw much support. You have not even said anything about your problem or your code.

excuse is that I used a translator.

Just want to add a physical dynamic type for a drawing done by hand

physics.addBody( <body>, “dynamic”, { <properties> } )

What’s your first/natural language?

Can you post your code?

My first language is portuguese.

Code:

local function draw_line(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(255,0,0);–math.random(255), math.random(255), math.random(255))

    lines[line_number].width = line_width

    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 = 0.5, bounce = 0, shape = {0, 0, dist_x, dist_y, 0, 0} } )

    prev_x = e.x

    prev_y = e.y

    line_number = line_number + 1

    print (line_number);

  elseif e.phase == “ended” then

  end

end

create various objects, wanted to create a single (one) object? 

as in the example Video…

You are not adding your line objects to a display group. Do that (look at the newLine documentation) at then apply the physics body to the display group.

I don’t know what lines[] is, but I think it is a table, not a display group. All you are doing is storing a list of lines, not a display group to control them.

Btw, when posting more than one line of code, use the   <>  button to show the code with line numbers.

ok, horacebury. Thank you.