resources/sceneabout.lua

Thu, 22 Aug 2013 19:50:12 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Aug 2013 19:50:12 +0200
changeset 0
bba7a2a225f6
permissions
-rw-r--r--

Flush progress with initial commit, improve application.

michael@0 1 -- Top of scene
michael@0 2 --print('This is a new scene!')
michael@0 3
michael@0 4 -- Initiate scene management
michael@0 5 local sceneloc = director:createScene()
michael@0 6 sceneloc.name = 'Scene: About'
michael@0 7
michael@0 8 -- Constants calculated
michael@0 9 local dsw = director.displayWidth
michael@0 10 local dsh = director.displayHeight
michael@0 11
michael@0 12 -- Fonts created
michael@0 13 local fontArial = director:createFont('fonts/Arial-96pt_bold.fnt')
michael@0 14 local fontSegoe = director:createFont('fonts/SegoeUI-64pt_bold.fnt')
michael@0 15
michael@0 16 function sceneloc:setUp(event)
michael@0 17 dbg.print('sceneloc:setUp')
michael@0 18
michael@0 19 ---- Cancel playing streams
michael@0 20 --audio:stopStream()
michael@0 21
michael@0 22 -- Print background
michael@0 23 local rectBack = director:createRectangle({
michael@0 24 x=0, y=0,
michael@0 25 w=dsw, h=dsh,
michael@0 26 strokeWidth=0,
michael@0 27 color={10, 74, 134}, alpha=1})
michael@0 28
michael@0 29 -- Initialize heading labels
michael@0 30 local labTitle = director:createLabel({
michael@0 31 x=0, y=-fontArial.height*1.5/6,
michael@0 32 hAlignment='centre', vAlignment='top',
michael@0 33 font=fontArial,
michael@0 34 text='Astrokaat Information',
michael@0 35 color={0xe0, 0xe0, 0xff}
michael@0 36 })
michael@0 37
michael@0 38 -- Initialize heading buttons
michael@0 39 local butBack = director:createSprite(fontSegoe.height, dsh-fontArial.height*1.5/4, 'images/butback1.png')
michael@0 40 butBack.yAnchor = 1
michael@0 41 butBack.xScale = .8
michael@0 42 butBack.yScale = .8
michael@0 43
michael@0 44 -- Initialize body text labels
michael@0 45 local rectAlph = director:createRectangle(fontSegoe.height, fontSegoe.height, dsw - fontSegoe.height * 2, dsh - fontArial.height * 2.25)
michael@0 46 rectAlph.color = color.black
michael@0 47 rectAlph.color.a = 64
michael@0 48 local labCont = director:createLabel({
michael@0 49 x=fontSegoe.height*2, y=-fontSegoe.height*3.25,
michael@0 50 w=dsw-fontSegoe.height*3, h=0,
michael@0 51 hAlignment='left', vAlignment='top',
michael@0 52 font=fontSegoe,
michael@0 53 text='Astrokaat - Space feline arcade game 0.7\nAstrokaat is a game where food is eaten and obstacles are avoided in a race against time.\n\nCopyright 2013 Michael Schloh von Bennewitz,\nThis software is made with Marmalade and distributed under the terms EUPL version 1.1'
michael@0 54 })
michael@0 55
michael@0 56 -- Good transitions: slideInL/R, shrinkGrow, crossFade, fadeTR/BL, pageTurn, progressVertical
michael@0 57 local transoptl = {transitionType = 'slideInL', transitionTime = 0.5}
michael@0 58 local transoptr = {transitionType = 'slideInR', transitionTime = 0.5}
michael@0 59 local transoptt = {transitionType = 'slideInT', transitionTime = 0.5}
michael@0 60 local transoptb = {transitionType = 'slideInB', transitionTime = 0.5}
michael@0 61
michael@0 62 -- Implement event handlers
michael@0 63 function labCont:touch(event)
michael@0 64 if event.phase == 'began' then
michael@0 65 if browser:isAvailable() then
michael@0 66 browser:launchURL('http://otpwcalc.europalab.com/')
michael@0 67 end
michael@0 68 end
michael@0 69 return true
michael@0 70 end
michael@0 71 labCont:addEventListener('touch', labCont)
michael@0 72
michael@0 73 function butBack:touch(event)
michael@0 74 if event.phase == 'began' then
michael@0 75 director:moveToScene(table.remove(nodeLastscene), table.remove(nodeLasttrans))
michael@0 76 end
michael@0 77 return true
michael@0 78 end
michael@0 79 butBack:addEventListener('touch', butBack)
michael@0 80 end
michael@0 81
michael@0 82 function sceneloc:tearDown(event)
michael@0 83 dbg.print('sceneloc:tearDown')
michael@0 84 --self.releaseResources()
michael@0 85 --self.<obj-here> = self.<obj-here>:removeFromParent()
michael@0 86 --self.obj0:removeFromParent()
michael@0 87 --self.obj1:removeFromParent()
michael@0 88 --self.obj0 = nil
michael@0 89 --self.obj1 = nil
michael@0 90 end
michael@0 91
michael@0 92 function sceneloc:enterPreTransition(event)
michael@0 93 dbg.print('sceneloc:enterPreTransition')
michael@0 94 end
michael@0 95
michael@0 96 function sceneloc:enterPostTransition(event)
michael@0 97 dbg.print('sceneloc:enterPostTransition')
michael@0 98 end
michael@0 99
michael@0 100 function sceneloc:exitPreTransition(event)
michael@0 101 dbg.print('sceneloc:exitPreTransition')
michael@0 102 end
michael@0 103
michael@0 104 function sceneloc:exitPostTransition(event)
michael@0 105 dbg.print('sceneloc:exitPostTransition')
michael@0 106 end
michael@0 107
michael@0 108 sceneloc:addEventListener({'setUp', 'tearDown', 'enterPreTransition',
michael@0 109 'enterPostTransition', 'exitPreTransition', 'exitPostTransition'}, sceneloc)
michael@0 110
michael@0 111 return sceneloc
michael@0 112

mercurial