How to draw a line and then when you release it it turns into a physics body

Hi i’m making a game where the user draws a line with their finger and then once you release it,it turns into a physic body ,i tried using other people’s methods but their lines aren’t as smooth.if the user draws a curve line i want the line to be made up of smaller line that way i think it will look better. could somebody help me with this?

this lines kinda looks like this ,if you’ll look closely it’s made up of smaller lines. [import]uid: 119325 topic_id: 22382 reply_id: 322382[/import]

Are you planning on it being static or dynamic? [import]uid: 52491 topic_id: 22382 reply_id: 89257[/import]

@peach it’s going to be dynamic

[import]uid: 119325 topic_id: 22382 reply_id: 89259[/import]

From your picture it looks like you would want a static line seeing as (at least what it looks to me) you want to draw a line for a ball to travel along.

For that you could use something like this - http://developer.anscamobile.com/code/easy-finger-drawing-undo-functionality

And where ever you see it create a rectangles or circle you would give that rectangles/circle physics properties.

The code above creates many mini circles and rectangles to give the look of a solid line being created by the users touch.

You could also use this system and set them as dynamic objects but even if you have gravity turned off, the lines will move as they are collided with and if you have gravity on each individual circle or rectangles will fall as soon as its drawn. Thats why I think static objects might be better for what you need. [import]uid: 69700 topic_id: 22382 reply_id: 89260[/import]

@ertzel

Thanks for replying,

But the code you suggested doesn’t seem to be as straight as the above picture.
Also what i meant was that the line will turn into a dynamic object after the user finishes drawing the line and lefts his/her finger up.
[import]uid: 119325 topic_id: 22382 reply_id: 89264[/import]

Could anyone please help me with the coding for this?

i’m new to programming.

Thanks. [import]uid: 119325 topic_id: 22382 reply_id: 89275[/import]

Dynamic is going to be much more complicated and as a new programmer you may want to learn the ropes first.

I suppose you’d likely look at using joints to join all the line parts together but yes, you may want to explore some sample code first. [import]uid: 52491 topic_id: 22382 reply_id: 89381[/import]