Draw a line and have a transition on it?

2 replies [Last post]
Marco De Vincenzi
User offline. Last seen 22 weeks 1 hour ago. Offline
Joined: 25 Jan 2011

I'd like to draw a line and let the object follow the line that I draw with a transition ( like in this game: https://itunes.apple.com/it/app/spy-mouse/id445992465?mt=8 )
Is it possible?

Replies

lost45
User offline. Last seen 1 year 29 weeks ago. Offline
Joined: 15 Jun 2011

This is impossible in Corona because the feature is not implemented and the only one who seemed to know anything about traversing lines, curves, etc. was the original CEO of Corona, but then he left to start a new company.

You would have to draw a line, collect all the points and then move from point to point but I would not use transition.to.

This is why I let my subscription expire, no (correct) feedback on most questions like this more of the time and the new forum staff brent and rob seem to really struggle to answer mathematically inclined questions :(

Brent Sorrentino
User offline. Last seen 14 hours 27 min ago. Offline
Staff
Joined: 28 Nov 2012

@"lost45": your subscription expired... and yet you're still here to chime in about that old, limited-purpose bezier curve thing from almost 2 years ago? Sounds familiar. ;)

Moving on... @MDVgamesStudios... this actually IS possible in Corona, with two potential methods that come to mind. One of these will require advanced math to evenly determine midpoints between "key points" along the spline/curve. The math is too detailed to discuss in this post, but you can read about some methods including the Catmull-Rom spline here:
http://en.wikipedia.org/wiki/Catmull-Rom#Catmull.E2.80.93Rom_spline

The "cheater" method, if you're already using physics, is to calculate (or pick up via touch-drag) a series of points along the "drawn gesture" path. Then, have a touch joint point that is attached to your object step along that path in an incremental timed series, point after point. With the proper damping on the touch joint, the object will smoothly follow behind, curving nicely as it tracks behind with a slight amount of "flexibility". I built a gesture track-follow simulation using this method over a year ago, and the result was quite nice... perhaps not as accurate as the math method, but certainly easier to implement.

Brent

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.