resources/sceneabout.lua

changeset 0
bba7a2a225f6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/resources/sceneabout.lua	Thu Aug 22 19:50:12 2013 +0200
     1.3 @@ -0,0 +1,112 @@
     1.4 +-- Top of scene
     1.5 +--print('This is a new scene!')
     1.6 +
     1.7 +-- Initiate scene management
     1.8 +local sceneloc = director:createScene()
     1.9 +sceneloc.name = 'Scene: About'
    1.10 +
    1.11 +-- Constants calculated
    1.12 +local dsw = director.displayWidth
    1.13 +local dsh = director.displayHeight
    1.14 +
    1.15 +-- Fonts created
    1.16 +local fontArial = director:createFont('fonts/Arial-96pt_bold.fnt')
    1.17 +local fontSegoe = director:createFont('fonts/SegoeUI-64pt_bold.fnt')
    1.18 +
    1.19 +function sceneloc:setUp(event)
    1.20 +    dbg.print('sceneloc:setUp')
    1.21 +
    1.22 +    ---- Cancel playing streams
    1.23 +    --audio:stopStream()
    1.24 +
    1.25 +    -- Print background
    1.26 +    local rectBack = director:createRectangle({
    1.27 +        x=0, y=0,
    1.28 +        w=dsw, h=dsh,
    1.29 +        strokeWidth=0,
    1.30 +        color={10, 74, 134}, alpha=1})
    1.31 +
    1.32 +    -- Initialize heading labels
    1.33 +    local labTitle = director:createLabel({
    1.34 +        x=0, y=-fontArial.height*1.5/6,
    1.35 +        hAlignment='centre', vAlignment='top',
    1.36 +        font=fontArial,
    1.37 +        text='Astrokaat Information',
    1.38 +        color={0xe0, 0xe0, 0xff}
    1.39 +    })
    1.40 +
    1.41 +    -- Initialize heading buttons
    1.42 +    local butBack = director:createSprite(fontSegoe.height, dsh-fontArial.height*1.5/4, 'images/butback1.png')
    1.43 +    butBack.yAnchor = 1
    1.44 +    butBack.xScale = .8
    1.45 +    butBack.yScale = .8
    1.46 +
    1.47 +    -- Initialize body text labels
    1.48 +    local rectAlph = director:createRectangle(fontSegoe.height, fontSegoe.height, dsw - fontSegoe.height * 2, dsh - fontArial.height * 2.25)
    1.49 +    rectAlph.color = color.black
    1.50 +    rectAlph.color.a = 64
    1.51 +    local labCont = director:createLabel({
    1.52 +        x=fontSegoe.height*2, y=-fontSegoe.height*3.25,
    1.53 +        w=dsw-fontSegoe.height*3, h=0,
    1.54 +        hAlignment='left', vAlignment='top',
    1.55 +        font=fontSegoe,
    1.56 +        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'
    1.57 +    })
    1.58 +
    1.59 +    -- Good transitions: slideInL/R, shrinkGrow, crossFade, fadeTR/BL, pageTurn, progressVertical
    1.60 +    local transoptl = {transitionType = 'slideInL', transitionTime = 0.5}
    1.61 +    local transoptr = {transitionType = 'slideInR', transitionTime = 0.5}
    1.62 +    local transoptt = {transitionType = 'slideInT', transitionTime = 0.5}
    1.63 +    local transoptb = {transitionType = 'slideInB', transitionTime = 0.5}
    1.64 +
    1.65 +    -- Implement event handlers
    1.66 +    function labCont:touch(event)
    1.67 +        if event.phase == 'began' then
    1.68 +            if browser:isAvailable() then
    1.69 +                browser:launchURL('http://otpwcalc.europalab.com/')
    1.70 +            end
    1.71 +        end
    1.72 +        return true
    1.73 +    end
    1.74 +    labCont:addEventListener('touch', labCont)
    1.75 +
    1.76 +    function butBack:touch(event)
    1.77 +        if event.phase == 'began' then
    1.78 +            director:moveToScene(table.remove(nodeLastscene), table.remove(nodeLasttrans))
    1.79 +        end
    1.80 +        return true
    1.81 +    end
    1.82 +    butBack:addEventListener('touch', butBack)
    1.83 +end
    1.84 +
    1.85 +function sceneloc:tearDown(event)
    1.86 +    dbg.print('sceneloc:tearDown')
    1.87 +    --self.releaseResources()
    1.88 +    --self.<obj-here> = self.<obj-here>:removeFromParent()
    1.89 +    --self.obj0:removeFromParent()
    1.90 +    --self.obj1:removeFromParent()
    1.91 +    --self.obj0 = nil
    1.92 +    --self.obj1 = nil
    1.93 +end
    1.94 +
    1.95 +function sceneloc:enterPreTransition(event)
    1.96 +    dbg.print('sceneloc:enterPreTransition')
    1.97 +end
    1.98 +
    1.99 +function sceneloc:enterPostTransition(event)
   1.100 +    dbg.print('sceneloc:enterPostTransition')
   1.101 +end
   1.102 +
   1.103 +function sceneloc:exitPreTransition(event)
   1.104 +    dbg.print('sceneloc:exitPreTransition')
   1.105 +end
   1.106 +
   1.107 +function sceneloc:exitPostTransition(event)
   1.108 +    dbg.print('sceneloc:exitPostTransition')
   1.109 +end
   1.110 +
   1.111 +sceneloc:addEventListener({'setUp', 'tearDown', 'enterPreTransition',
   1.112 +    'enterPostTransition', 'exitPreTransition', 'exitPostTransition'}, sceneloc)
   1.113 +
   1.114 +return sceneloc
   1.115 +

mercurial