New to C#: Multiple Splash Screen Question
by Stephen Scott · in Torque X 2D · 01/19/2009 (9:30 pm) · 2 replies
Hey, So I'm pretty new to C#.
I currently have two splash screens (GG's TX logo and my company's logo) that load one after the other. The fade in fade out works fine with the first one, but the second one starts to fade in at the same time (behind) the first logo.
How would I force the splashStyle to use the time after the second logo disappears (after second 8), since there isn't a BeginFadeTime. And I pretty much just modded the Splashscreen tutorial from the TDN and the TX Book.
Help a poor Artist trying to script? lol
I currently have two splash screens (GG's TX logo and my company's logo) that load one after the other. The fade in fade out works fine with the first one, but the second one starts to fade in at the same time (behind) the first logo.
How would I force the splashStyle to use the time after the second logo disappears (after second 8), since there isn't a BeginFadeTime. And I pretty much just modded the Splashscreen tutorial from the TDN and the TX Book.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GarageGames.Torque.Platform;
using GarageGames.Torque.Core;
using GarageGames.Torque.Util;
using GarageGames.Torque.Sim;
using GarageGames.Torque.GUI;
using GarageGames.Torque.T2D;
using GarageGames.Torque.SceneGraph;
using GarageGames.Torque.MathUtil;
namespace StarterGame2D
{
//[TorqueXmlSchemaType]
class GuiSplashScreen : GUISplash, IGUIScreen
{
GUISplashStyle splashStyle = new GUISplashStyle();
public GuiSplashScreen()
{
// create the Style for our splash ad
splashStyle.FadeInSec = 2; // black to image 2 seconds
splashStyle.FadeOutSec = 2; // image to black 2 seconds
splashStyle.FadeWaitSec = 3; // still image for 4 seconds
splashStyle.Bitmap = @"dataimagesSplash_TX_1024x768.png";
splashStyle.PreserveAspectRatio = true;
//splashStyle.Anchor = AnchorFlags.All;
// set some info for this control
Name = "GuiSplashScreen";
Style = splashStyle;
Size = new Vector2(1024, 768);
// create a black letterbox
// only visible on widescreen displays
GUIStyle lbStyle = new GUIStyle();
lbStyle.IsOpaque = true;
lbStyle.FillColor[0] = Color.Black;
GUIControl letterbox = new GUIControl();
letterbox.Style = lbStyle;
GUICanvas.Instance.LetterBoxControl = letterbox;
OnFadeFinished = GuiSplashScreen2;
}
public void GuiSplashScreen2()
{
// create the Style for our splash ad
//GUISplashStyle splashStyle2 = new GUISplashStyle();
GUISplashStyle splashStyle2 = new GUISplashStyle();
splashStyle2.FadeInSec = 10; // black to image 2 seconds
splashStyle2.FadeOutSec = 2; // image to black 2 seconds
splashStyle2.FadeWaitSec = 3; // still image for 4 seconds
splashStyle2.Bitmap = @"dataimagesSplash_AS_1024x768.png";
splashStyle2.PreserveAspectRatio = true;
// set some info for this control
Name = "GuiSplashScreen2";
Style = splashStyle2;
Size = new Vector2(1024, 768);
OnFadeFinished = OnSplashFinished;
// create a black letterbox
// only visible on widescreen displays
GUIStyle lbStyle = new GUIStyle();
lbStyle.IsOpaque = true;
lbStyle.FillColor[0] = Color.Black;
GUIControl letterbox = new GUIControl();
letterbox.Style = lbStyle;
GUICanvas.Instance.LetterBoxControl = letterbox;
}
//Option A - Go right into the game
public void OnSplashFinished()
{
Game.Instance.ShowMainMenu();
}
}
}Help a poor Artist trying to script? lol
About the author
I'm the Founder of Algitt Studios LLC. With Algitt I create Indie Titles as the programmer, artist, designer and sound guy. I also work full-time as the Art Director for Exato Game Studios and as a programmer on their unannounced project.
Torque Owner Sean Monahan
See how your second splash calls OnSplashFinished with the OnFadeFinished delegate? I would do something similar with your second splash. So rather than have both splash screens in the same class make a base SplashScreen class and have two (or more) splash screens: TXSplashScreen, MySplashScreen, etc. Then you can have a method in Game.cs that creates a new splash screen, similar to Game.Instance.ShowMainMenu.
So you'd have something like:
public void GuiSplashScreen(string splashImagePath) { // create the Style for our splash ad //GUISplashStyle splashStyle2 = new GUISplashStyle(); GUISplashStyle splashStyle2 = new GUISplashStyle(); splashStyle2.FadeInSec = 10; // black to image 2 seconds splashStyle2.FadeOutSec = 2; // image to black 2 seconds splashStyle2.FadeWaitSec = 3; // still image for 4 seconds splashStyle2.Bitmap = splashImagePath; splashStyle2.PreserveAspectRatio = true; // set some info for this control Name = "GuiSplashScreen2"; Style = splashStyle2; Size = new Vector2(1024, 768); OnFadeFinished = OnSplashFinished; // create a black letterbox // only visible on widescreen displays GUIStyle lbStyle = new GUIStyle(); lbStyle.IsOpaque = true; lbStyle.FillColor[0] = Color.Black; GUIControl letterbox = new GUIControl(); letterbox.Style = lbStyle; GUICanvas.Instance.LetterBoxControl = letterbox; } public void OnSplashFinished() { Game.Instance.OnSplashFinished(); }Then in Game.cs you'd have an OnSplashFinished method:
public void OnSplashFinished() { // An index defined in Game.cs to keep track of which splash page // we are on. _splashIndex++; switch(_splashIndex) { case 1: // Show the splash page whose index is 1 break; case 2: // etc, etc. break; default: // The splash index is not defined. // This means we have no more splash pages. ShowMainMenu(); break; } }Not sure if this will work without a hitch (or at all) but that's where I'd start.