-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyEvents.lua
More file actions
52 lines (41 loc) · 1.67 KB
/
myEvents.lua
File metadata and controls
52 lines (41 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- eventListenerCallsModule
module(..., package.seeall)
local storyboard = require( "storyboard" )
local myData = require( "scripts.myData" )
local perspective=require("scripts.perspective")
local goToPage
local myTransition
----------------------------------------------------------------------------------------
-- Screen Touch Event -- Swipe to Turn Page
----------------------------------------------------------------------------------------
function onScreenTouch( event )
if event.phase == "ended" or event.phase == "cancelled" then
-- Detect swipe direction and change scene
if event.xStart < event.x and (event.x - event.xStart) >= 30 then
previousPage()
return true
elseif event.xStart > event.x and (event.xStart - event.x) >= 30 then
nextPage()
return true
end
myData.playText = 0
end
return true -- IMPORTANT, return true to keep touches from going through to object beneath
end
----------------------------------------------------------------------------------------
-- turns the page
----------------------------------------------------------------------------------------
function previousPage()
goToPage = myData.currentPage - 1
if goToPage < myData.firstPage then goToPage = myData.firstPage end
storyboard.gotoScene( ("scripts.page" .. goToPage), "slideRight", 800 )
end
function zoomOut()
print("zoom out")
--perspective:pointAndZoom(w/2, h/2, 1, 1000, function() print("Point and Zoom") end, nil)
end
function nextPage()
goToPage = myData.currentPage + 1
if goToPage > myData.lastPage then goToPage = myData.firstPage end
storyboard.gotoScene( ("scripts.page" .. goToPage), "slideLeft", 800 )
end