diff -r 000000000000 -r bba7a2a225f6 resources/scenerules.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/resources/scenerules.lua Thu Aug 22 19:50:12 2013 +0200 @@ -0,0 +1,169 @@ +-- Top of scene +--print('This is a new scene!') + +-- Initiate scene management +local sceneloc = director:createScene() +sceneloc.name = 'Scene: Scoring' + +-- 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') + + ---- Cancel playing streams + --audio:stopStream() + + -- 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 Scoring', + color={0xe0, 0xe0, 0xff} + }) + + -- Initialize heading buttons + local butBack = director:createSprite(fontSegoe.height, dsh-fontArial.height*1.5/4, 'images/butback1.png') + butBack.yAnchor = 1 + butBack.xScale = .8 + butBack.yScale = .8 + local butInfo = director:createSprite(dmw+labTitle.wText/2+fontSegoe.height/2, dsh-fontArial.height*1.5/4, 'images/butinfo.png') + butInfo.yAnchor = 1 + butInfo.xScale = .8 + butInfo.yScale = .8 + + -- 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 labFood = director:createLabel({ + -- x=fontSegoe.height*1.5, y=-fontSegoe.height * 2.75, + -- w=dsw-fontSegoe.height*3, h=0, + -- hAlignment='left', vAlignment='top', + -- font=fontSegoe, + -- text='Food (Positive Points)' + --}) + local labExplic = director:createLabel({ + x=fontSegoe.height*1.5, y=-fontSegoe.height * 2.75, + vAlignment='top', font=fontSegoe, + text='Food nourishes, but obstacles harm the Astrokaat' + }) + local spriteCatthumb = director:createSprite(fontSegoe.height*2, dsh-fontSegoe.height*6.75, 'textures/cattin_thumb.png') + local labCattin = director:createLabel({ + x=fontSegoe.height*2, y=-fontSegoe.height*6.75, + vAlignment='top', font=fontSegoe, text='+2 points' + }) + local spriteCheesethumb = director:createSprite(fontSegoe.height*8.5, dsh-fontSegoe.height*6.75, 'textures/cheese_thumb.png') + local labCheese = director:createLabel({ + x=fontSegoe.height*8.5, y=-fontSegoe.height*6.75, + vAlignment='top', font=fontSegoe, text='+2 points' + }) + local spriteFischthumb = director:createSprite(dsw-fontSegoe.height*5.5, dsh-fontSegoe.height*6.75, 'textures/fischko_thumb.png') + local labFischkopf = director:createLabel({ + x=dsw-fontSegoe.height*5.5, y=-fontSegoe.height*6.75, + vAlignment='top', font=fontSegoe, text='+2 points' + }) +-- local labObst = director:createLabel({ +-- x=fontSegoe.height*1.5, y=-fontSegoe.height * 7, +-- w=dsw-fontSegoe.height*3, h=0, +-- hAlignment='left', vAlignment='top', +-- font=fontSegoe, +-- text='Obstacles (Negative Points)' +-- }) + local spriteCometblau = director:createSprite(fontSegoe.height*2.5, dsh-fontSegoe.height*10, 'textures/comet1_thumb.png') + local labCattin = director:createLabel({ + x=fontSegoe.height*2, y=-fontSegoe.height*10, + vAlignment='top', font=fontSegoe, text='-1 points' + }) + local spriteCometrot = director:createSprite(fontSegoe.height*7, dsh-fontSegoe.height*10, 'textures/comet2_thumb.png') + local labCheese = director:createLabel({ + x=fontSegoe.height*6.5, y=-fontSegoe.height*10, + vAlignment='top', font=fontSegoe, text='-1 points' + }) + local spriteAster1 = director:createSprite(dsw-fontSegoe.height*9, dsh-fontSegoe.height*10, 'textures/asteroid1.png') + spriteAster1.xScale = .1875 + spriteAster1.yScale = .1875 + local labFischkopf = director:createLabel({ + x=dsw-fontSegoe.height*10, y=-fontSegoe.height*10, + vAlignment='top', font=fontSegoe, text='-2 points' + }) + local spriteAster2 = director:createSprite(dsw-fontSegoe.height*4.5, dsh-fontSegoe.height*10, 'textures/asteroid2.png') + spriteAster2.xScale = .1875 + spriteAster2.yScale = .1875 + local labFischkopf = director:createLabel({ + x=dsw-fontSegoe.height*5.5, y=-fontSegoe.height*10, + vAlignment='top', font=fontSegoe, text='-2 points' + }) + + -- 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 butBack:touch(event) + if event.phase == 'began' then + director:moveToScene(table.remove(nodeLastscene), table.remove(nodeLasttrans)) + end + return true + end + butBack:addEventListener('touch', butBack) +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 +