|
1 -- Your app starts here! |
|
2 --require('mobdebug').start() |
|
3 |
|
4 -- Deny backlight dimming |
|
5 device:setBacklightAlways() |
|
6 |
|
7 -- Track scene history (for back sequence) |
|
8 --local szLasttrans = '' |
|
9 --local nodeLastscene |
|
10 nodeLastscene = {} |
|
11 nodeLasttrans = {} |
|
12 |
|
13 -- Load scene blocks |
|
14 sceneIntro = dofile('sceneintro.lua') |
|
15 sceneRules = dofile('scenerules.lua') |
|
16 sceneBegin = dofile('scenebegin.lua') |
|
17 sceneGover = dofile('scenegover.lua') |
|
18 sceneAbout = dofile('sceneabout.lua') |
|
19 sceneHelp = dofile('scenehelp.lua') |
|
20 |
|
21 -- Good transitions: slideInL/R, shrinkGrow, crossFade, fadeTR/BL, pageTurn, progressVertical |
|
22 local transoptl = {transitionType = 'slideInL', transitionTime = 0.5} |
|
23 local transoptr = {transitionType = 'slideInR', transitionTime = 0.5} |
|
24 local transoptt = {transitionType = 'slideInT', transitionTime = 0.5} |
|
25 local transoptb = {transitionType = 'slideInB', transitionTime = 0.5} |
|
26 |
|
27 -- Implement global event handlers |
|
28 function hardkeyPressed(event) |
|
29 if event.phase == 'released' then |
|
30 if event.keyCode == key.back then |
|
31 if nodeLastscene[1] ~= nil then |
|
32 director:moveToScene(table.remove(nodeLastscene), table.remove(nodeLasttrans)) |
|
33 --return true |
|
34 else |
|
35 --os.exit(0) |
|
36 system.quit() |
|
37 end |
|
38 end |
|
39 end |
|
40 end |
|
41 system:addEventListener('key', hardkeyPressed) |
|
42 |
|
43 -- Not sure if this is buggy |
|
44 --function getOuttaHere(event) |
|
45 -- --os.exit(0) |
|
46 -- system.quit() |
|
47 --end |
|
48 --system:addEventListener('exit', getOuttaHere) |
|
49 |
|
50 -- Bootstrap initial scene |
|
51 director:setCurrentScene(nil) |
|
52 director:moveToScene(sceneIntro) |
|
53 |