I need to move an object as if its driving, and am looking for a simpler way to do so than what I am currently doing.
What I have
local function rotateLeft90() vehicle.rotation = 0 end local function rotateBackwards() vehicle.rotation = 90 end local function DriveLeft() transition.to( vehicle, { time=200, x=(vehicle.x - 50), y=(vehicle.y) } ) end local function setToPosition() vehicle.x = 280 vehicle.y = 515 print(vehicle.x, " ", vehicle.y) end local function MoveDown() transition.to( vehicle, { time=3500, x=(vehicle.x), y=(vehicle.y + 600) } ) end local function MoveUp() transition.to( vehicle, { time=3500, x=(vehicle.x), y=(vehicle.y - 620) } ) end local function start() timer.performWithDelay(2600, MoveDown) timer.performWithDelay(6000, rotateLeft90) timer.performWithDelay(6100, DriveLeft) timer.performWithDelay(6300, rotateBackwards) timer.performWithDelay(6350, MoveUp) end start()
All it is doing is moving a image round with transition.to, and lining them up accordingly with the timers. I feel this is a very inefficient way of doing things. Is there a better way to do this than how I am?
Possibly making the image follow a trail? I’m not sure how to start with this. Possibly a bunch of predefined points, that I can translate the image to? I’m really at a loss as to how the best way to go about this would be.
Any help is appreciated.