Bear with me, my programming experience is pretty much slim to none. 
I am getting close to finishing my first project, but I have one major roadblock: I am trying to figure out how to drag my User_ball object along a specific path.
The ‘path’ I want my object to follow is a series of display objects, and I want the user to be able to freely drag the ball along the path.
Currently all I am able to do is drag the ball. I’ve tried changing parts of the code attempting to get the ball’s movement to be confined to a specific course, but I haven’t been able to achieve what I want.
Originally I thought the answer would be to use bezier curves, but unfortunately all of the examples I’ve seen - draw a line and click an animate button, draw a curve and immediately following ended phase of the touch the object follows the path etc… - are not what I want.
By the way, the only “curves” in my game are right-angles.
Another thought I had was to create a table of invisible ‘points’ or ‘locations’ and have the user drag the ball between the various points… only problem is I have no idea how to code something like that. :]
Any help would be greatly appreciated.
Here is the code I use to drag the ball:
[lua]-- adding a function that will allow the user to drag the ball
function User_ball:touch( event )
if event.phase == “began” then
display.getCurrentStage():setFocus(self, event.id)
self.isFocus = true
self.markX = self.x – store x location of object
self.markY = self.y – store y location of object
elseif event.phase == “moved” then
local x = (event.x - event.xStart) + self.markX
local y = (event.y - event.yStart) + self.markY
self.x, self.y = x,y – move object based on calculations above
elseif event.phase == “ended” or event.phase == “cancelled” then
display.getCurrentStage():setFocus(self, nil)
self.isFocus = false
end
– stop further propagation of touch event
return true
end
User_ball:addEventListener( “touch”, User_ball )[/lua]
-Saer [import]uid: 148623 topic_id: 35544 reply_id: 335544[/import]
