drawn line,becomes physical object

Hi ,

How can i draw a line and then turn it into a physical object after pushing a button?

[import]uid: 37866 topic_id: 7227 reply_id: 307227[/import]

A straight line? [import]uid: 10903 topic_id: 7227 reply_id: 25556[/import]

so you would first draw your line…

local myLine = display.newLine(0,50, 50, 150)  

then you would create a function that runs when you press your button…

local function myFunction ( event )  
physics.addBody(myLine, "static", {friction = 0.1, bounce = 0.1})  
end  

and of course at the start of your game code you need to do
local physics = require(“physics”)
and
physics.start()

you then would have your button call the “myFunction” function when its clicked [import]uid: 19620 topic_id: 7227 reply_id: 25574[/import]

I think he’s talking about someone in the app using their fingers to paint a line, then the line becomes an object when you press the button. [import]uid: 38631 topic_id: 7227 reply_id: 25614[/import]

yea well hopefully that will be of some help, best of luck with the rest. [import]uid: 19620 topic_id: 7227 reply_id: 25623[/import]

tnx for all your replies :slight_smile:

andrewp - I think he’s talking about someone in the app using their fingers to paint a line, then the line becomes an object when you press the button.

exacly what im looking for ;D [import]uid: 37866 topic_id: 7227 reply_id: 25658[/import]

I used carlos’ point reduction code available here to create lines and make them visible. The thing i can’t figure out is how to make the shape of the line the physics shape. Also, i’d like to make full shapes instead of lines… Any idea? [import]uid: 41757 topic_id: 7227 reply_id: 25930[/import]

@madjack : I don’t think physic body is work on newLine, did u try it ? [import]uid: 12088 topic_id: 7227 reply_id: 25931[/import]

@yuewah : you just get the standard rectangle body shape [import]uid: 41757 topic_id: 7227 reply_id: 25934[/import]

The physics body will work with the new line, but the physics body is not aligned very well with the actual line, this is a bug that i believe ansca knows about. i have no idea how to make the curved lines work out in that way, i looked into it for a good while but there is just not enough information and it seems impossible [import]uid: 19620 topic_id: 7227 reply_id: 25942[/import]

I have the same problem with the alignment, and have not jet found a fix for it.
My goal is to let people draw shapes which will turn in to physical objects. (the principle of games like crayon physics or magic pen). Anyone else tried this? [import]uid: 41757 topic_id: 7227 reply_id: 25946[/import]

i got my idea from magic pen ;D [import]uid: 37866 topic_id: 7227 reply_id: 26225[/import]

not sure if it is on the roadmap. Line physic get a lot of fun ! [import]uid: 12088 topic_id: 7227 reply_id: 25945[/import]