easy way for frequency timer

Anybody has an easy way to do a frequency timer.

I want a body to move up for half a second and then move down for half a second.

I am having a hard time with the timer.performWithDelay as it seems the forces seem additive aswell.

Thanks

[import]uid: 8192 topic_id: 1812 reply_id: 301812[/import]

You can do that with transition.to() call with the onComplete calling a listener that starts the movement in the opposite direction. See https://developer.anscamobile.com/content/animation#transition.to_target_params_

If you are still having problems, post your code here and we can help you out.

-Tom [import]uid: 7559 topic_id: 1812 reply_id: 5424[/import]

This is what I have so far. I am sure there are more than one mistake. Thanks

[code]
upanddown = function ()
transition.to(mo,{time = 500, mo.y = mo.y + 100, onComplete})
end

local function onComplete (self, event)
transition.to(mo,{time = 500, mo.y = mo.y - 100 })
end

mo.onComplete = onComplete
mo:addEventListener( “onComplete”, mo)

moFlyState1 = function () – Fly Around
mo.y = randomY
mo.isVisible = true
mo.bodyType = “dynamic”
mo:applyLinearImpulse(2,0,0,0)
timer.performWithDelay( 10, upanddown, 0)
timer.performWithDelay( 2000000 , moFlyState2 ,1)
end

[code]

[import]uid: 8192 topic_id: 1812 reply_id: 5430[/import]