creditsOverlay = nil creditsUpdateThread = nil local creditsStarsUV = 1.0 local bgStarsProp = nil local starScrollRate = 0 local creditsAnim = nil local creditsAnim2 = nil local creditsText = nil local creditsText2 = nil function creditsSetup() inputCallback = creditsOnInput local creditsOverlayGfx = MOAIGfxQuad2D.new() creditsOverlayGfx:setTexture( BLACK_BOX_IMAGE ) creditsOverlayGfx:setRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) creditsOverlay = MOAIProp2D.new() creditsOverlay:setDeck( creditsOverlayGfx ) creditsOverlay:setColor( 0, 0, 0, 1 ) creditsOverlay:setPriority( 10 ) creditsText = MOAITextBox.new() creditsText:setFont( font ) creditsText:setString( CREDITS_TEXT1 ) creditsText:setAlignment ( MOAITextBox.CENTER_JUSTIFY ) creditsText:setRect( 0, 0, 580, 1200 ) creditsText:setLoc( 190, 544 ) creditsText:setColor ( 1, 1, 1, 1 ) creditsText:setPriority( 11 ) creditsAnim = creditsText:moveLoc( 0, -2944, 0, 40, MOAIEaseType.LINEAR ) creditsAnim:setListener( MOAITimer.EVENT_TIMER_END_SPAN, onCreditsOver ) creditsText2 = MOAITextBox.new() creditsText2:setFont( font ) creditsText2:setString( CREDITS_TEXT2 ) creditsText2:setAlignment ( MOAITextBox.CENTER_JUSTIFY ) creditsText2:setRect( 0, 0, 580, 1200 ) creditsText2:setLoc( 190, 1744 ) creditsText2:setColor ( 1, 1, 1, 1 ) creditsText2:setPriority( 11 ) creditsAnim2 = creditsText2:moveLoc( 0, -2944, 0, 40, MOAIEaseType.LINEAR ) bgStarsTex = MOAITexture.new() bgStarsTex:load( GAMEPLAY_BG_STARS ) bgStarsTex:setWrap(true) bgStars = MOAIGfxQuad2D.new() bgStars:setTexture( bgStarsTex ) bgStars:setRect( 0, 0, 577, 524 ) bgStars:setUVRect( 0, 0, 1, 1 ) bgStarsProp = MOAIProp2D.new() bgStarsProp:setDeck( bgStars ) bgStarsProp:setLoc( 190, 0 ) bgStarsProp:setPriority( 11 ) layer:insertProp( bgStarsProp ) if MOAIEnvironment.osBrand == "PSM" then starScrollRate = -0.0001 else starScrollRate = 0.0001 end creditsUpdateThread = MOAIThread.new() creditsUpdateThread:run( creditsUpdate ) layer:insertProp( creditsOverlay ) layer:insertProp( creditsText ) layer:insertProp( creditsText2 ) -- initialize values -- allocate resources -- spin up threads end function creditsUpdate() while true do bgStars:setUVRect( 0, creditsStarsUV, 1, 1 + creditsStarsUV ) if MOAIEnvironment.osBrand == "PSM" then bgStarsProp:updateUVs() end creditsStarsUV = creditsStarsUV - starScrollRate if creditsStarsUV < 0.0 then creditsStarsUV = 1.0 end coroutine.yield () end end function creditsTeardown() -- destroy credits textbox, aggressively creditsUpdateThread:stop() creditsAnim:stop() creditsAnim2:stop() if MOAIEnvironment.osBrand == "PSM" then MOAIPSM.destroyTextBox( creditsText.textBoxID ) MOAIPSM.destroyTextBox( creditsText2.textBoxID ) end layer:clear() -- spin down threads -- clean up resources end function creditsOnInput( key, isDown ) if (key == KEY_CONFIRM) and not isDown then SFX["MENU_BACK"]:play() changeGameState(GAME_STATE_MENU) elseif key == KEY_CANCEL and not isDown then -- z SFX["MENU_BACK"]:play() changeGameState(GAME_STATE_MENU) end end function onCreditsOver() changeGameState(GAME_STATE_MENU) end