Drawing path, followed by sprite, path visible on screen

Hi,

At the moment i’am in verry hard need to draw lines on the screen witch will be followed by a sprite.

So user draw the path, the sprite will follow the path, that’s verry much it.

I really do not now where to start in Corona (gameedition) to accomplish this.

I need the exact same thing as the game flight control.

Thanks for any help already. [import]uid: 2734 topic_id: 1727 reply_id: 301727[/import]

I think this would work if you created a polyline object and then continuously added short segments to it as the user traced a line.

See here: https://developer.anscamobile.com/content/display-objects#Polylines

Basically, once the user starts drawing, sample their finger’s x,y position at short intervals (maybe 1/10th of a second?) using timer.performWithDelay(), and then on each timer cycle add a new connecting line segment to each new point. You’ll get different amounts of “smoothing” in the line depending on the length of your samples, so you may need to experiment here.

At the same time, add each new (x,y) point to an array. Then, you can make any object “follow” that line by having it follow those stored points. To get the “Flight Control” effect, you’ll also want to rotate the sprite so that it’s facing in the same direction as the current line segment. (Each line segment has two points, and you can use those points to calculate the proper angle that the sprite should be facing.)

The rest of this depends on your game logic: for example, in Flight Control, if a line is drawn “very near” a plane, the plane decides to “follow” that line, and aligns itself with the line from that point onwards. But if the line isn’t drawn closely enough to the plane, the plane ignores it and nothing happens.
[import]uid: 3007 topic_id: 1727 reply_id: 5129[/import]

Evank,

Thanks for pointing me in the right directions, i will try, use and share it!!

Thanks. [import]uid: 2734 topic_id: 1727 reply_id: 5139[/import]