Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function touchPlay(event)
- local bounds = buttonPlay.contentBounds
- local isWithinBounds = bounds.xMin <= event.x and bounds.xMax >= event.x and bounds.yMin <= event.y and bounds.yMax >= event.y
- if event.phase == "began" then
- buttonPlay:prepare("play2")
- buttonPlay:play()
- display.getCurrentStage():setFocus(buttonPlay, event.id)
- buttonPlay.isFocused = true
- elseif buttonPlay.isFocused then
- if event.phase == "moved" then
- if isWithinBounds then
- buttonPlay:prepare("play2")
- else
- buttonPlay:prepare("play1")
- end
- buttonPlay:play()
- elseif event.phase == "ended" or event.phase == 'cancelled' then
- buttonPlay:prepare("play1")
- buttonPlay:play()
- display.getCurrentStage():setFocus(buttonPlay, nil)
- buttonPlay.isFocused = false
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement