Below is the code I’m using: When I added the function (see blue) the transition did not start - not even one rotation. I know this is basic but I’m not getting it. Thanks
local movePath = {}
movePath[1] = { x=680, y=253, time=8000 }
movePath[2] = { x=680, y=840, time=8000 }
movePath[3] = { x=105, y=840, time=8000 }
movePath[4] = { x=105, y=253, time=8000 }
movePath[5] = { x=384, y=253, time=8000 }
local function distBetween( x1, y1, x2, y2 )
local xFactor = x2 - x1
local yFactor = y2 - y1
local dist = math.sqrt((xFactor*xFactor) + (yFactor*yFactor))
return dist
end
local function setPath( object, path, params )
local delta = params.useDelta or nil
local deltaX = 0
local deltaY = 0
local constant = params.constantTime or nil
local ease = params.easingMethod or easing.linear
local tag = params.tag or nil
local delay = params.delay or 0
local speedFactor = 1
if ( delta and delta == false ) then
–if delta = true, the object’s path will be relative to its starting position
–if dealta = false or ommitted, the path points will be explicit screen positions
deltaX = object.x
deltaY = object.y
end
if ( constant ) then
–this sets a constant rate of movement
local dist = distBetween( object.x, object.y, deltaX+path[1].x, deltaY+path[1].y )
speedFactor = constant/dist
end
for i = 1,#path do
local segmentTime = 500
–if “constant” is defined, refactor transition time based on distance between points
if ( constant ) then
local dist
if ( i == 1 ) then
dist = distBetween( object.x, object.y, deltaX+path[i].x, deltaY+path[i].y )
else
dist = distBetween( path[i-1].x, path[i-1].y, path[i].x, path[i].y )
end
segmentTime = dist*speedFactor
else
–if this path segment has a custom time, use it
if ( path[i].time ) then segmentTime = path[i].time end
end
–if this segment has custom easing, override the default method (if any)
if ( path[i].easingMethod ) then ease = path[i].easingMethod end
function moveIt()
moveHole = transition.to( object, { tag=tag, time=segmentTime, x=deltaX+path[i].x, y=deltaY+path[i].y, delay=delay, transition=ease, onComplete=moveIt** } )**
delay = delay + segmentTime
end
end
end
setPath(pocket1, movePath, { useDelta=true, constantTime=8000, easingMethod=easing.inOutQuad, delay=200, tag=“moveObject” } )
setPath(pocketSensor1, movePath, { useDelta=true, constantTime=8000, easingMethod=easing.inOutQuad, delay=200, tag=“moveObject” } )