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