introTimers = {} introStartTime = 0 introCurrentProp = nil introCurrentSFX = nil function loadIntroImage( assetFilename ) local gfxObj = MOAIGfxQuad2D.new () gfxObj:setTexture( INTRO_DIR .. assetFilename ) gfxObj:setRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) gfxObj:setUVRect ( 0, 0, 1, 1 ) return gfxObj end function loadSplashImage() local gfxObj = MOAIGfxQuad2D.new () gfxObj:setTexture( SPLASH_SCREEN ) gfxObj:setRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) gfxObj:setUVRect ( 0, 0, 1, 1 ) return gfxObj end local imageA = nil local imageB = nil local imageC = nil local imageD = nil local imageE = nil local imageF = nil local imageG = nil local imageH = nil local imageSplash = nil function createIntroProp( gfxObj, priority ) priority = priority or 10 local propObj = MOAIProp2D.new() propObj:setDeck( gfxObj ) propObj:setBlendMode( MOAIProp2D.GL_SRC_ALPHA, MOAIProp2D.GL_ONE_MINUS_SRC_ALPHA ) propObj:setLoc( 0, 0 ) propObj:setPriority( priority ) layer:insertProp( propObj ) return propObj end function loadIntroImageCentered( assetFilename, priority ) priority = priority or 10 local gfxObj = MOAIGfxQuad2D.new () gfxObj:setTexture( assetFilename ) gfxObj:setRect( -SCREEN_WIDTH * 0.5, -SCREEN_HEIGHT * 0.5, SCREEN_WIDTH * 0.5, SCREEN_HEIGHT * 0.5 ) gfxObj:setUVRect ( 0, 0, 1, 1 ) local propObj = MOAIProp2D.new() propObj:setDeck( gfxObj ) propObj:setBlendMode( MOAIProp2D.GL_SRC_ALPHA, MOAIProp2D.GL_ONE_MINUS_SRC_ALPHA ) propObj:setLoc( SCREEN_WIDTH * 0.5, SCREEN_HEIGHT * 0.5 ) propObj:setPriority( priority ) layer:insertProp( propObj ) return propObj end function introSetup() inputCallback = introOnInput local curTime = MOAISim.getCurrentTime() imageA = loadIntroImage( 'A.png' ) print( MOAISim.getCurrentTime() - curTime ) MOAIPSM.forceUpdateFrameTime(); introCurrentSFX = SFX["CRICKETS"] introCurrentSFX:setLooping(true) introCurrentSFX:play() introCurrentProp = createIntroProp( imageA ) introCurrentProp:setColor( 1, 1, 1, 0 ) introCurrentProp:moveColor( 0, 0, 0, 1, 1, MOAIEaseType.LINEAR ) introStartTime = MOAISim.getDeviceTime() table.insert( introTimers, performWithDelay( 3000, introStep3 ) ) table.insert( introTimers, performWithDelay( 5000, introStep5 ) ) table.insert( introTimers, performWithDelay( 6000, introStep6 ) ) table.insert( introTimers, performWithDelay( 9000, introStep7 ) ) table.insert( introTimers, performWithDelay( 12000, introStep13 ) ) table.insert( introTimers, performWithDelay( 14250, introStep15 ) ) table.insert( introTimers, performWithDelay( 16000, introStep18 ) ) table.insert( introTimers, performWithDelay( 18500, introStep20 ) ) table.insert( introTimers, performWithDelay( 26000, introStep26 ) ) table.insert( introTimers, performWithDelay( 35000, introStep34 ) ) table.insert( introTimers, performWithDelay( 35500, introStep345 ) ) table.insert( introTimers, performWithDelay( 36000, introStep35 ) ) -- fade in first image for 1 second -- play crickets for 3 seconds -- at 3 seconds, play ufo_blocks_begin -- cut to second image at 5 seconds -- start ufo_blocks_row_up at 5 seconds -- start music at 6 seconds -- crossfade to third image from 7 seconds to 8 seconds -- instant cut to fourth image at 13 seconds -- instant cut to fifth image at 15 seconds -- instant cut to sixth image at 18 seconds -- crossfade to seventh image at 20 seconds (G) to 23 -- crossfade to eighth image at 26 to 28 -- at 34 seconds: -- [11/17/2013, 9:43:44 PM] Kevin Oke: a white square or whatever starting at very small at the centre of the screen and scaling up really quickly to fill up the whole screen, and once fully filled with white, go to the title screen, and then fade out the white (alpha) until transparent, with the title screen underneath -- [11/17/2013, 9:47:14 PM] Kevin Oke: say roughly .5 seconds for the white out scaling up, another .5 for the white to fade out completely -- load images and timing -- kick off sequence -- when sequence is over, change to splash screen if backgroundMusic:isPlaying() then backgroundMusic:stop() end -- initialize values -- allocate resources -- spin up threads end function introStep3() introCurrentSFX:stop() introCurrentSFX = SFX["TRACTOR_BEAM"] introCurrentSFX:play() end function introStep5() layer:removeProp( introCurrentProp ) imageB = loadIntroImage( 'B.png' ) introCurrentProp = createIntroProp( imageB ) introCurrentSFX = SFX["ROW_UPDATE_PERFORM"] introCurrentSFX:play() end function introStep6() backgroundMusic:play() end function introStep7() introCurrentProp:moveColor( 0, 0, 0, -1, 1, MOAIEaseType.LINEAR ) -- TODO: remove from layer after fade out is complete imageC = loadIntroImage( 'C.png' ) introCurrentProp = createIntroProp( imageC ) introCurrentProp:setColor( 1, 1, 1, 0 ) introCurrentProp:moveColor( 0, 0, 0, 1, 1, MOAIEaseType.LINEAR ) end function introStep13() imageD = loadIntroImage( 'D.png' ) layer:removeProp( introCurrentProp ) introCurrentProp = createIntroProp( imageD ) end function introStep15() imageE = loadIntroImage( 'E.png' ) layer:removeProp( introCurrentProp ) introCurrentProp = createIntroProp( imageE ) end function introStep18() imageF = loadIntroImage( 'F.png' ) layer:removeProp( introCurrentProp ) introCurrentProp = createIntroProp( imageF ) end function introStep20() imageG = loadIntroImage( 'G.png' ) introCurrentProp:moveColor( 0, 0, 0, -1, 3, MOAIEaseType.LINEAR ) -- TODO: remove from layer after fade out is complete introCurrentProp = createIntroProp( imageG ) introCurrentProp:setColor( 1, 1, 1, 0 ) introCurrentProp:moveColor( 0, 0, 0, 1, 3, MOAIEaseType.LINEAR ) end function introStep26() imageH = loadIntroImage( 'H.png' ) introCurrentProp:moveColor( 0, 0, 0, -1, 2, MOAIEaseType.LINEAR ) -- TODO: remove from layer after fade out is complete introCurrentProp = createIntroProp( imageH ) introCurrentProp:setColor( 1, 1, 1, 0 ) introCurrentProp:moveColor( 0, 0, 0, 1, 2, MOAIEaseType.LINEAR ) end function introStep34() introCurrentProp = loadIntroImageCentered( GLOM_OVER_IMAGE, 11 ) introCurrentProp:setScl( 0, 0 ) introCurrentProp:moveScl( 1.3, 1.3, 0.5, MOAIEaseType.LINEAR ) end function introStep345() imageSplash = loadSplashImage() introCurrentProp:moveColor( 0, 0, 0, -1, 0.5, MOAIEaseType.LINEAR ) createIntroProp( imageSplash ) end function introStep35() changeGameState(GAME_STATE_SPLASH) end function introTeardown() for i, v in ipairs(introTimers) do v:stop() end introCurrentSFX:stop() layer:clear() if imageA ~= nil then MOAIPSM.unloadTexture( imageA.textureID ) imageA = nil end if imageB ~= nil then MOAIPSM.unloadTexture( imageB.textureID ) imageB = nil end if imageC ~= nil then MOAIPSM.unloadTexture( imageC.textureID ) imageC = nil end if imageD ~= nil then MOAIPSM.unloadTexture( imageD.textureID ) imageD = nil end if imageE ~= nil then MOAIPSM.unloadTexture( imageE.textureID ) imageE = nil end if imageF ~= nil then MOAIPSM.unloadTexture( imageF.textureID ) imageF = nil end if imageG ~= nil then MOAIPSM.unloadTexture( imageG.textureID ) imageG = nil end if imageH ~= nil then MOAIPSM.unloadTexture( imageH.textureID ) imageH = nil end -- spin down threads -- clean up resources end function introOnInput( key, isDown ) if (key == KEY_CONFIRM or key == KEY_PAUSE) and not isDown then SFX["MENU_SELECT"]:play() changeGameState(GAME_STATE_SPLASH) end end