This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Back And Forth easing generator

By: lvs on Sep 28th, 2013  |  syntax: Lua  |  size: 0.58 KB  |  views: 63  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  local backAndForthGenerator = function (ease)
  2.     return function(t, tMax, start, delta)
  3.         if t / tMax < 0.5 then
  4.             return ease(t, tMax * 0.5, start, delta)
  5.         else
  6.             return ease(tMax - t, tMax * 0.5, start, delta)
  7.         end
  8.     end
  9. end
  10.  
  11. display.setStatusBar(display.statusBarHidden)
  12. local square = display.newRect( 0, 0, 50, 50 )
  13. local _W, _H = display.contentWidth, display.contentHeight
  14.  
  15. square.x = _W * 0.5
  16. square.y = _H * 0.8
  17.  
  18. transition.to(square, {time = 1000, y = 30, transition = backAndForthGenerator(easing.outExpo), iterations = 10})
clone this paste RAW Paste Data