Advertisement
lvs

Untitled

lvs
Jan 7th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. local function touchPlay(event)
  2.     local bounds = buttonPlay.contentBounds
  3.         local isWithinBounds = bounds.xMin <= event.x and bounds.xMax >= event.x and bounds.yMin <= event.y and bounds.yMax >= event.y
  4.     if event.phase == "began" then
  5.         buttonPlay:prepare("play2")
  6.         buttonPlay:play()
  7.         display.getCurrentStage():setFocus(buttonPlay, event.id)
  8.         buttonPlay.isFocused = true
  9.     elseif buttonPlay.isFocused then
  10.         if event.phase == "moved" then
  11.             if isWithinBounds then
  12.                             buttonPlay:prepare("play2")
  13.                     else
  14.                             buttonPlay:prepare("play1")
  15.                     end
  16.             buttonPlay:play()
  17.         elseif event.phase == "ended" or event.phase == 'cancelled' then
  18.             buttonPlay:prepare("play1")
  19.             buttonPlay:play()
  20.             display.getCurrentStage():setFocus(buttonPlay, nil)
  21.             buttonPlay.isFocused = false
  22.         end
  23.     end
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement