Game Development Reference
In-Depth Information
Go for the Gusto
We now have the dialog component built for our splash screen launcher, but we
can take it one step further and enhance the visual effects if we want. A nice touch
that is common among many splash screens is the fade-in and fade-out transition
effect. You may skip this step if you do not want this extra functionality, or if you
feel that doing so would not be an effective use of your time.
Thankfully, .NET WinForms support an Opacity property that lets you modify the
transparency factor of a window and all the contained child controls. We can uti-
lize this property in conjunction with a couple of timer objects to create a fading
effect that will make our splash dialogs look really slick!
The fading effect will be orchestrated by two timers in addition to the first one
used to time the duration of the splash dialog.
private void FadeInTimer_Tick(object sender, System.EventArgs e)
{
if (this.Opacity < 0.9)
this.Opacity += 0.1;
else
{
FadeInTimer.Stop();
if (_splashScreen.LoadingJobs == null ||
_splashScreen.LoadingJobs.Count <= 0)
{
DisplayTimer.Start();
}
else
{
ProcessJobs();
}
}
}
The fade-in timer will be started in the form load event instead of the display
timer. When the form is fully visible and if the dialog is timed, the display timer
will fire and begin counting towards closing the dialog. The event code for the dis-
play timer presented earlier will require a small modification to support the new
fading feature. The change is shown in the following code.
private void DisplayTimer_Tick(object sender, System.EventArgs e)
{
DisplayTimer.Stop();
Search Nedrilad ::




Custom Search