michael@0: -- Top of scene michael@0: --print('This is a new scene!') michael@0: michael@0: -- Initiate scene management michael@0: local sceneloc = director:createScene() michael@0: sceneloc.name = 'Scene: Scoring' michael@0: michael@0: -- Constants calculated michael@0: local dsw = director.displayWidth michael@0: local dsh = director.displayHeight michael@0: local dmw = director.displayCenterX michael@0: local dmh = director.displayCenterY michael@0: michael@0: -- Instantiate common fonts michael@0: local fontSegoe = director:createFont('fonts/SegoeUI-64pt_bold.fnt') michael@0: local fontArial = director:createFont('fonts/Arial-96pt_bold.fnt') michael@0: michael@0: function sceneloc:setUp(event) michael@0: dbg.print('sceneloc:setUp') michael@0: michael@0: ---- Cancel playing streams michael@0: --audio:stopStream() michael@0: michael@0: -- Print background michael@0: local rectBack = director:createRectangle({ michael@0: x=0, y=0, michael@0: w=dsw, h=dsh, michael@0: strokeWidth=0, michael@0: color={10, 74, 134}, alpha=1}) michael@0: michael@0: -- Initialize heading labels michael@0: local labTitle = director:createLabel({ michael@0: x=0, y=-fontArial.height*1.5/6, michael@0: hAlignment='centre', vAlignment='top', michael@0: font=fontArial, michael@0: text='Astrokaat Scoring', michael@0: color={0xe0, 0xe0, 0xff} michael@0: }) michael@0: michael@0: -- Initialize heading buttons michael@0: local butBack = director:createSprite(fontSegoe.height, dsh-fontArial.height*1.5/4, 'images/butback1.png') michael@0: butBack.yAnchor = 1 michael@0: butBack.xScale = .8 michael@0: butBack.yScale = .8 michael@0: local butInfo = director:createSprite(dmw+labTitle.wText/2+fontSegoe.height/2, dsh-fontArial.height*1.5/4, 'images/butinfo.png') michael@0: butInfo.yAnchor = 1 michael@0: butInfo.xScale = .8 michael@0: butInfo.yScale = .8 michael@0: michael@0: -- Initialize body text labels michael@0: local rectalph = director:createRectangle(fontSegoe.height, fontSegoe.height, dsw - fontSegoe.height * 2, dsh - fontArial.height * 2.25) michael@0: rectalph.color = color.black michael@0: rectalph.color.a = 64 michael@0: --local labFood = director:createLabel({ michael@0: -- x=fontSegoe.height*1.5, y=-fontSegoe.height * 2.75, michael@0: -- w=dsw-fontSegoe.height*3, h=0, michael@0: -- hAlignment='left', vAlignment='top', michael@0: -- font=fontSegoe, michael@0: -- text='Food (Positive Points)' michael@0: --}) michael@0: local labExplic = director:createLabel({ michael@0: x=fontSegoe.height*1.5, y=-fontSegoe.height * 2.75, michael@0: vAlignment='top', font=fontSegoe, michael@0: text='Food nourishes, but obstacles harm the Astrokaat' michael@0: }) michael@0: local spriteCatthumb = director:createSprite(fontSegoe.height*2, dsh-fontSegoe.height*6.75, 'textures/cattin_thumb.png') michael@0: local labCattin = director:createLabel({ michael@0: x=fontSegoe.height*2, y=-fontSegoe.height*6.75, michael@0: vAlignment='top', font=fontSegoe, text='+2 points' michael@0: }) michael@0: local spriteCheesethumb = director:createSprite(fontSegoe.height*8.5, dsh-fontSegoe.height*6.75, 'textures/cheese_thumb.png') michael@0: local labCheese = director:createLabel({ michael@0: x=fontSegoe.height*8.5, y=-fontSegoe.height*6.75, michael@0: vAlignment='top', font=fontSegoe, text='+2 points' michael@0: }) michael@0: local spriteFischthumb = director:createSprite(dsw-fontSegoe.height*5.5, dsh-fontSegoe.height*6.75, 'textures/fischko_thumb.png') michael@0: local labFischkopf = director:createLabel({ michael@0: x=dsw-fontSegoe.height*5.5, y=-fontSegoe.height*6.75, michael@0: vAlignment='top', font=fontSegoe, text='+2 points' michael@0: }) michael@0: -- local labObst = director:createLabel({ michael@0: -- x=fontSegoe.height*1.5, y=-fontSegoe.height * 7, michael@0: -- w=dsw-fontSegoe.height*3, h=0, michael@0: -- hAlignment='left', vAlignment='top', michael@0: -- font=fontSegoe, michael@0: -- text='Obstacles (Negative Points)' michael@0: -- }) michael@0: local spriteCometblau = director:createSprite(fontSegoe.height*2.5, dsh-fontSegoe.height*10, 'textures/comet1_thumb.png') michael@0: local labCattin = director:createLabel({ michael@0: x=fontSegoe.height*2, y=-fontSegoe.height*10, michael@0: vAlignment='top', font=fontSegoe, text='-1 points' michael@0: }) michael@0: local spriteCometrot = director:createSprite(fontSegoe.height*7, dsh-fontSegoe.height*10, 'textures/comet2_thumb.png') michael@0: local labCheese = director:createLabel({ michael@0: x=fontSegoe.height*6.5, y=-fontSegoe.height*10, michael@0: vAlignment='top', font=fontSegoe, text='-1 points' michael@0: }) michael@0: local spriteAster1 = director:createSprite(dsw-fontSegoe.height*9, dsh-fontSegoe.height*10, 'textures/asteroid1.png') michael@0: spriteAster1.xScale = .1875 michael@0: spriteAster1.yScale = .1875 michael@0: local labFischkopf = director:createLabel({ michael@0: x=dsw-fontSegoe.height*10, y=-fontSegoe.height*10, michael@0: vAlignment='top', font=fontSegoe, text='-2 points' michael@0: }) michael@0: local spriteAster2 = director:createSprite(dsw-fontSegoe.height*4.5, dsh-fontSegoe.height*10, 'textures/asteroid2.png') michael@0: spriteAster2.xScale = .1875 michael@0: spriteAster2.yScale = .1875 michael@0: local labFischkopf = director:createLabel({ michael@0: x=dsw-fontSegoe.height*5.5, y=-fontSegoe.height*10, michael@0: vAlignment='top', font=fontSegoe, text='-2 points' michael@0: }) michael@0: michael@0: -- Good transitions: slideInL/R, shrinkGrow, crossFade, fadeTR/BL, pageTurn, progressVertical michael@0: local transoptl = {transitionType = 'slideInL', transitionTime = 0.5} michael@0: local transoptr = {transitionType = 'slideInR', transitionTime = 0.5} michael@0: local transoptt = {transitionType = 'slideInT', transitionTime = 0.5} michael@0: local transoptb = {transitionType = 'slideInB', transitionTime = 0.5} michael@0: michael@0: -- Implement event handlers michael@0: function butInfo:touch(event) michael@0: if event.phase == 'began' then michael@0: table.insert(nodeLastscene, director:getCurrentScene()) michael@0: table.insert(nodeLasttrans, transoptb) michael@0: director:moveToScene(sceneAbout, transoptt) michael@0: end michael@0: return true michael@0: end michael@0: butInfo:addEventListener('touch', butInfo) michael@0: michael@0: function butBack:touch(event) michael@0: if event.phase == 'began' then michael@0: director:moveToScene(table.remove(nodeLastscene), table.remove(nodeLasttrans)) michael@0: end michael@0: return true michael@0: end michael@0: butBack:addEventListener('touch', butBack) michael@0: end michael@0: michael@0: function sceneloc:tearDown(event) michael@0: dbg.print('sceneloc:tearDown') michael@0: --self.releaseResources() michael@0: --self. = self.:removeFromParent() michael@0: --self.obj0:removeFromParent() michael@0: --self.obj1:removeFromParent() michael@0: --self.obj0 = nil michael@0: --self.obj1 = nil michael@0: end michael@0: michael@0: function sceneloc:enterPreTransition(event) michael@0: dbg.print('sceneloc:enterPreTransition') michael@0: end michael@0: michael@0: function sceneloc:enterPostTransition(event) michael@0: dbg.print('sceneloc:enterPostTransition') michael@0: end michael@0: michael@0: function sceneloc:exitPreTransition(event) michael@0: dbg.print('sceneloc:exitPreTransition') michael@0: end michael@0: michael@0: function sceneloc:exitPostTransition(event) michael@0: dbg.print('sceneloc:exitPostTransition') michael@0: end michael@0: michael@0: sceneloc:addEventListener({'setUp', 'tearDown', 'enterPreTransition', michael@0: 'enterPostTransition', 'exitPreTransition', 'exitPostTransition'}, sceneloc) michael@0: michael@0: return sceneloc michael@0: