Question about creating a body from a line

I created a vertical vector line using the display.newLine() command. When I converted the line to a physics body (not custom dimensions) however, the center of the body is set at the top of the line rather than the center of the line. It’s pretty much vertically shifted half the length of the line. I know I can make a custom shape, but I was wondering why the body isn’t automatically created to the line’s dimensions.

Thanks
[import]uid: 14678 topic_id: 5643 reply_id: 305643[/import]

Here’s the code that illustrates my problem.

[lua]local physics=require “physics”
physics.start()
physics.setDrawMode(“hybrid”)
physics.setGravity(0,0)
local background = display.newImage(“background1.png”)
local line=display.newLine(25,150,25,350)
line:setColor(237,28,36,150)
line.width=5
physics.addBody(line,{isSensor=true})[/lua] [import]uid: 14678 topic_id: 5643 reply_id: 19428[/import]

same problem here… [import]uid: 160159 topic_id: 5643 reply_id: 121837[/import]

Hey oromonetti, looks like this thread is originally from January 2011 but I recently had a similar issue with using lines as physics objects. Basically, it ends up being pretty nasty business and it’s best to just go with a rectangle when possible.

Check out my recent thread for more detailed info:
https://developer.coronalabs.com/forum/2012/08/30/using-box2d-line-object [import]uid: 172008 topic_id: 5643 reply_id: 121880[/import]

thank you TozyJay :slight_smile:
[import]uid: 160159 topic_id: 5643 reply_id: 121987[/import]

same problem here… [import]uid: 160159 topic_id: 5643 reply_id: 121837[/import]

Hey oromonetti, looks like this thread is originally from January 2011 but I recently had a similar issue with using lines as physics objects. Basically, it ends up being pretty nasty business and it’s best to just go with a rectangle when possible.

Check out my recent thread for more detailed info:
https://developer.coronalabs.com/forum/2012/08/30/using-box2d-line-object [import]uid: 172008 topic_id: 5643 reply_id: 121880[/import]

thank you TozyJay :slight_smile:
[import]uid: 160159 topic_id: 5643 reply_id: 121987[/import]