I’m trying to apply physics attributes to a line. As far as I can tell this is not possible so I then moved on to trying to generate a triangle shape. I’m getting a crash when I try this route. To draw the line it captures the x,y of the first touch point and if you drag it makes the end of the line wherever you release. Here’s my current code that does not work:
[code]
local bkg = display.newImage( “paper_bkg.png”, true )
bkg.x = display.contentWidth/2
bkg.y = display.contentHeight/2
local physics = require(“physics”)
physics.start()
physics.setGravity( 0, 0 ) – no gravity in any direction
local function spawnLine( event )
local phase = event.phase
if “ended” == phase then
local line = display.newLine( event.xStart,event.yStart, event.x,event.y )
local thirdLegX = event.xStart - 1
local thirdLegY = event.yStart - 1
triangleShape = { event.xStart,event.yStart, event.x,event.y, thirdLegX, thirdLegY }
physics.addBody( line, { friction=0.6, shape=triangleShape } )
line:setColor( 255, 102, 102, 255 )
line.width = 2
end
end
bkg:addEventListener( “touch”, spawnLine )
physics.setDrawMode( “hybrid” )
[/code] [import]uid: 13868 topic_id: 5287 reply_id: 305287[/import]