splashTimer = nil local splashTextAnim = nil local splashTextProp = nil function splashTextFadeOut() splashTextAnim = splashTextProp:moveColor(0, 0, 0, -0.9, 1, MOAIEaseType.LINEAR) splashTextAnim:setListener( MOAIAction.EVENT_STOP, splashTextFadeIn ) end function splashTextFadeIn() splashTextAnim = splashTextProp:moveColor(0, 0, 0, 0.9, 1, MOAIEaseType.LINEAR) splashTextAnim:setListener( MOAIAction.EVENT_STOP, splashTextFadeOut ) end function splashSetup() inputCallback = splashOnInput if MOAIEnvironment.osBrand == "PSM" then -- do some sort of aggressive cleanup of intro assets end local splashScreenGfx = MOAIGfxQuad2D.new() splashScreenGfx:setTexture( SPLASH_SCREEN ) splashScreenGfx:setRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) splashScreenGfx:setUVRect( 0, 0, 1, 1 ) local splashScreenProp = MOAIProp2D.new() splashScreenProp:setDeck( splashScreenGfx ) splashScreenProp:setLoc( 0, 0 ) layer:insertProp( splashScreenProp ) local splashTextGfx = MOAIGfxQuad2D.new() splashTextGfx:setTexture( SPLASH_TEXT ) splashTextGfx:setRect( 0, 0, 312, 50 ) splashTextGfx:setUVRect( 0, 0, 1, 1 ) splashTextProp = MOAIProp2D.new() splashTextProp:setDeck( splashTextGfx ) splashTextProp:setLoc( 324, 490 ) splashTextProp:setBlendMode( MOAIProp2D.GL_SRC_ALPHA, MOAIProp2D.GL_ONE_MINUS_SRC_ALPHA ) layer:insertProp( splashTextProp ) splashTextFadeOut() -- TODO: 'wait until music is done, then after 5 seconds of silence go back to intro' -- will need to support cancelling all of this if the user decides to go to the main menu. if not backgroundMusic:isPlaying() then backgroundMusic:play() end -- initialize values -- allocate resources -- spin up threads end function splashTeardown() if splashTimer ~= nil then splashTimer:stop() splashTimer = nil end layer:clear() -- spin down threads -- clean up resources end function splashFromIntro() -- set up timer so after 1 minute, go back to the intro -- if the user chooses to go to the main menu, kill this timer. local timeElapsed = MOAISim.getDeviceTime() - introStartTime splashTimer = performWithDelay( (63 - timeElapsed) * 1000, gotoIntro ) end function splashFromMainMenu() -- set up timer so after 10 seconds, go back to the intro -- if the user chooses to go to the main menu, kill this timer. splashTimer = performWithDelay( 10 * 1000, gotoIntro ) end function gotoIntro() changeGameState(GAME_STATE_INTRO) end function splashOnInput( key, isDown ) -- If SPACE or ENTER was pressed if (key == KEY_SPACEBAR or key == KEY_CONFIRM or key == KEY_PAUSE) and not isDown then SFX["MENU_SELECT"]:play() changeGameState(GAME_STATE_MENU) end end