Guest User

Untitled

a guest
Jan 21st, 2019
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fadeOut ( event )
  2. transition.to(yes1, {time=2000, alpha=0})
  3. transition.to(yes2, {time=2000, alpha=0})
  4. ...
  5. transition.to(funny3, {time=2000, alpha=0})
  6. transition.to(funny4, {time=2000, alpha=0})
  7. timer.performWithDelay(2000, onShakeComplete)
  8. end
  9.  
  10. responses = {yes1, yes2, yes3, yes4, yes5, yes6, yes7, yes8, yes9, yes10,
  11. no1, no2, no3, no4, no5, maybe1, maybe2, maybe3, maybe4, maybe5,
  12. funny1, funny2, funny3, funny4}
  13.  
  14. local shaking = false
  15.  
  16. -- reset shaking flag after a shake is completed
  17. local function onShakeComplete()
  18. shaking = false
  19. end
  20.  
  21. local function onShake (event)
  22. if event.isShake and not shaking then
  23. shaking = true
  24. local object = responses[math.random(1,20)]
  25. transition.to(object, {time=2000, alpha=1})
  26. timer.performWithDelay(4000, fadeOut)
  27. end
  28. end
  29. Runtime:addEventListener("accelerometer", onShake)
  30.  
  31. -- true if we have a shake happening right now
  32. local shaking = false
  33.  
  34. -- reset shaking flag after a shake is completed
  35. local function onShakeComplete()
  36. shaking = false
  37. end
  38.  
  39. local function onShake (event)
  40. if event.isShake and not shaking then
  41. local object = responses[math.random(1,20)]
  42. transition.to(object, {time=2000, alpha=1})
  43. timer.performWithDelay(4000, fadeOut)
  44. timer.performWithDelay(4000, onShakeComplete)
  45. shaking = true
  46. end
  47. end
RAW Paste Data