Im trying to make an object following the path of a cosine wave… And when the object reaches the end of the wave, I want it to return via the same exact path. Problem Ive had is the object follows a slightly different wave path on the way back… I think its because I am not sure how to determine the wavelength… and send the object back when it hasnt quite reached its original X axis.
[code]
local frequency = 100
local amplitude = 15
local continue = true
local function moveOrb()
if orb1.y <= 960 and continue == true then
orb1:translate( (math.cos( system.getTimer() / frequency ) * amplitude), 10 )
else
continue = false
end
if orb1.y >= 0 and continue == false then
orb1:translate( -(math.cos( system.getTimer() / frequency ) * amplitude), -10 )
else
continue = true
end
end
Runtime:addEventListener(“enterFrame”, moveOrb) [import]uid: 28912 topic_id: 8940 reply_id: 308940[/import]