diff -r 000000000000 -r bba7a2a225f6 resources/sceneintro.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/resources/sceneintro.lua Thu Aug 22 19:50:12 2013 +0200 @@ -0,0 +1,135 @@ +-- Top of scene +--print('This is a new scene!') + +-- Initiate scene management +local sceneloc = director:createScene() +sceneloc.name = 'Scene: Intro' + +-- Constants calculated +local dsw = director.displayWidth +local dsh = director.displayHeight +local dmw = director.displayCenterX +local dmh = director.displayCenterY + +-- Instantiate common fonts +local fontSegoe = director:createFont('fonts/SegoeUI-64pt_bold.fnt') +local fontArial = director:createFont('fonts/Arial-96pt_bold.fnt') + +function sceneloc:setUp(event) + dbg.print('sceneloc:setUp') + + -- Prepare playing streams + --audio:stopStream() + if not audio:isStreamPlaying() then + audio:loadStream('sounds/vapour.mp3') + audio:playStream('sounds/vapour.mp3', true) + end + + -- Print background + local rectBack = director:createRectangle({ + x=0, y=0, + w=dsw, h=dsh, + strokeWidth=0, + color={10, 74, 134}, alpha=1}) + + -- Initialize heading labels + local labTitle = director:createLabel({ + x=0, y=-fontArial.height*1.5/6, + hAlignment='centre', vAlignment='top', + font=fontArial, + text='Astrokaat Instructions', + color={0xe0, 0xe0, 0xff} + }) + + -- Initialize heading buttons + local butInfo = director:createSprite(dsw-fontSegoe.height, dsh-fontArial.height*1.5/6, 'images/butinfo.png') + butInfo.xAnchor = 1 + butInfo.yAnchor = 1 + + -- Initialize body text labels + local rectalph = director:createRectangle(fontSegoe.height, fontSegoe.height, dsw - fontSegoe.height * 2, dsh - fontArial.height * 2.25) + rectalph.color = color.black + rectalph.color.a = 64 + local labCont = director:createLabel({ + x=fontSegoe.height*2, y=-fontSegoe.height*3.25, + w=dsw-fontSegoe.height*3, h=0, + hAlignment='left', vAlignment='top', + font=fontSegoe, + text='Keep Astrokaat alive by maintaining her health. Eat flying food while avoiding space obstacles. Direct Astrokaat about by pushing on the screen.' + }) + + -- Initialize body buttons + local butRules = director:createSprite(fontSegoe.height*2, fontSegoe.height*2, 'images/butrules.png') + local butStart = director:createSprite(dsw-fontSegoe.height*2, fontSegoe.height*2, 'images/butstart.png') + butStart.xAnchor = 1 + butStart.yAnchor = 0 + + -- Good transitions: slideInL/R, shrinkGrow, crossFade, fadeTR/BL, pageTurn, progressVertical + local transoptl = {transitionType = 'slideInL', transitionTime = 0.5} + local transoptr = {transitionType = 'slideInR', transitionTime = 0.5} + local transoptt = {transitionType = 'slideInT', transitionTime = 0.5} + local transoptb = {transitionType = 'slideInB', transitionTime = 0.5} + + -- Implement event handlers + function butInfo:touch(event) + if event.phase == 'began' then + table.insert(nodeLastscene, director:getCurrentScene()) + table.insert(nodeLasttrans, transoptb) + director:moveToScene(sceneAbout, transoptt) + end + return true + end + butInfo:addEventListener('touch', butInfo) + + function butRules:touch(event) + if event.phase == 'began' then + table.insert(nodeLastscene, director:getCurrentScene()) + table.insert(nodeLasttrans, transoptr) + director:moveToScene(sceneRules, transoptl) + end + return true + end + butRules:addEventListener('touch', butRules) + + function butStart:touch(event) + if event.phase == 'began' then + table.insert(nodeLastscene, director:getCurrentScene()) + table.insert(nodeLasttrans, transoptl) + director:moveToScene(sceneBegin, transoptr) + end + return true + end + butStart:addEventListener('touch', butStart) +end + +function sceneloc:tearDown(event) + dbg.print('sceneloc:tearDown') + --self.releaseResources() + --self. = self.:removeFromParent() + --self.obj0:removeFromParent() + --self.obj1:removeFromParent() + --self.obj0 = nil + --self.obj1 = nil +end + +function sceneloc:enterPreTransition(event) + dbg.print('sceneloc:enterPreTransition') +end + +function sceneloc:enterPostTransition(event) + dbg.print('sceneloc:enterPostTransition') +end + +function sceneloc:exitPreTransition(event) + dbg.print('sceneloc:exitPreTransition') +end + +function sceneloc:exitPostTransition(event) + dbg.print('sceneloc:exitPostTransition') +end + +sceneloc:addEventListener({'setUp', 'tearDown', 'enterPreTransition', + 'enterPostTransition', 'exitPreTransition', 'exitPostTransition'}, sceneloc) + +return sceneloc +