Moving along a fixed track

I’d like to creat a track for an object which can be dragged using. Touch point, but which can’t escape the track.

Normally, I love this sort of challenge in Corona, but I just can’t figure this one…

Any ideas guys?
Matt [import]uid: 8271 topic_id: 8078 reply_id: 308078[/import]

Have you tried setting up dense barriers with physics then just using a drag on touch function? [import]uid: 10903 topic_id: 8078 reply_id: 28968[/import]

Well I’d start by looking at the Bezier curve stuff Carlos put in Code Exchange:
http://developer.anscamobile.com/code/bezier-object-along-curves-path [import]uid: 12108 topic_id: 8078 reply_id: 28969[/import]

I’ve thought about dense barriers (does it really matter what the density value of a static object is?) but it seems inelegant and the bezier curve would require far too many objects to be smooth, wouldn’t it? (If each curve segment got converted to a physics object) [import]uid: 8271 topic_id: 8078 reply_id: 28981[/import]

Is it possible to convert the curves into physics objects? [import]uid: 10903 topic_id: 8078 reply_id: 28983[/import]

Well, I suppose. Might be a bit of work, but their segments could. Wouldn’t want to have to re-calc the curve on each enterFrame though… [import]uid: 8271 topic_id: 8078 reply_id: 28988[/import]

I think you need to give us more background about your specific use case. Your reference to recalculating the curve every frame makes me wonder what the hell you’re doing.

bezier curve would require far too many objects to be smooth, wouldn’t it

I haven’t looked at Carlos’ code specifically, but then that’s why I said I would start by looking there. In general the whole point of bezier curves is that you can parametrically define a smooth curve with very few points (as opposed to trying to define a curve with lots of straight lines.) [import]uid: 12108 topic_id: 8078 reply_id: 29032[/import]

Well, it’s a good point, actually. I was thinking about a bezier curve which is changing shape while still being a physics object (or series of.)

But you’re right - if the curve were transformed into two parallel tracks it could easily be used to contain something. [import]uid: 8271 topic_id: 8078 reply_id: 29035[/import]