Timed Fading Splash Screen

Started by kevin, September 19, 2010, 03:24:08 PM

Previous topic - Next topic

kevin

 Timed Fading Splash Screen

   This is a quick example of how to create a splash screen that's timer based,rather than frame rate based.   In this example the splash screen has a user definable number of the millseconds to appear (1000 milliseconds is 1 second to us humans), the routine fades the content in and out, by taking the elapsed time (since the routine started) and scaling it into an angle. The angle is then used to control the intensity of the screen contents.  Which in this case is just a couple of the shade boxes and some text, but you can do the same with logos and what not.   By using sinus we get a more rounded fade in and out.  
 

PlayBASIC Code: [Select]
   LoadFont "arial",1,48,0

Show_Screen(5000)


Function Show_Screen(EffectTime)


CentY=GetScreenHeight()/2

StartTime=Timer()
EndTime=Timer()+effectTime
Repeat

CurrentTime=Timer()

TimePast#=CurrentTime-StartTime
Scale#=TimePast#/effectTime

ColourLEvel#=sin(180*Scale#)*100

C1=rgbfade(rgb(100,80,155),ColourLevel#)
C2=rgbfade(rgb(40,30,20),ColourLevel#)

ShadeBox 0,0,GetScreenWidth(),CentY,C1,c1,c2,c2
ShadeBox 0,CentY,GetScreenWidth(),GetScreenHeight(),C2,c2,c1,c1

ink rgbfade($ffffffff,ColourLevel#)
Xpos=GetScreenWidth()/2
Ypos=CentY -(GetFontHeight(1)/2)
CenterText Xpos,Ypos,"www.UnderwareDesign.com"

Sync
until CurrentTime>EndTime

EndFunction