In Box2D, you would use a prismatic joint. In Corona terms, this is a piston joint (http://developer.anscamobile.com/content/game-edition-physics-joints#Piston_joint) however, there is an issue concerning certain types of joints you may wish to keep track of: https://developer.anscamobile.com/forum/2010/10/30/pivot-joints-and-apparent-elasticity
The core issue here is that certain joints are not performing as they, very reliably, do in other Box2D-based systems (eg: Flash, Cocos2D)
So, for the time being (that is, until a bug fix is found, mostly likely) your solution will have to be to have a function called by the enterFrame event which adjusts the x value of your object.
It’s a little brute force (ok, extremely) but the only hard and fast solution.
Correction… (not an edit)
Ok, I still stand by what I just wrote, but the solution I found in my game (due to piston joints and the isFixedRotation property cancelling each other out) is to create walls either side of the object being restricted in movement.
In my case I want to stop blocks from shifting sideways, so I’ve got a 1px invisible wall either side of each block, static and with no friction, bounce, etc.
A modification of this could be to have a circle body fixed (welded or pivot’ed) to the overall body being restricted and place the restricting bodies around the smaller piece. Like a runner on a drawer.
Unfortunately, excessive forces on the larger body will pull it away from the ‘runner’ object - no matter the strength of the joint between the two (see the issue in the link above) so I would go with my ‘restricting walls either side’ solution, if I were you.
Hope this helps.
Matt. [import]uid: 8271 topic_id: 5997 reply_id: 20594[/import]