Splash screen does not load
by Temasek Polytechnic (#0001) · in Torque X 2D · 02/25/2008 (1:03 am) · 1 replies
Hi, my splashscreen does not load when i run it, instead it straight away loads the scene.Could anyone help??
//game.cs
protected override void BeginRun()
{
base.BeginRun();
// go to splash screen
GUIUtil.InitGUIScreens("PlatformerDemo.UI");
GUIStyle splashStyle = new GUIStyle();
GUISceneview splash = new GUISceneview();
splash.Style = splashStyle;
GUICanvas.Instance.SetContentControl("SplashScreen");
// load the test level
SceneLoader.Load(@"data\levels\my_level_26.txscene");
// set the parallax manager's target object
T2DSceneCamera camera = T2DSceneGraph.Instance.Camera as T2DSceneCamera;
ParallaxManager.Instance.ParallaxTarget = camera;
// create game gui
GUIStyle playStyle = new GUIStyle();
GUISceneview play = new GUISceneview();
play.Name = "PlayScreen";
play.Style = playStyle;
GUICanvas.Instance.SetContentControl(play);
PlatformerDemoGUI.Instance.GUI.Folder = GUICanvas.Instance;
// register sound groups
SoundManager.Instance.RegisterSoundGroup(@"data\sound\music");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\general");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\drill");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\dragon_dirt.xsb", @"data\sound\dragon.xwb");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\dragon_grass.xsb", @"data\sound\dragon.xwb");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\dragon_wood.xsb", @"data\sound\dragon.xwb");
// grab the sound categories
_soundEffectsCategory = Engine.SFXDevice.GetCategory("Default");
_musicCategory = Engine.SFXDevice.GetCategory("Music");
// game start
_gameStart = Time;
// start music loop
_indoorMusic = "indoor_music";
_outdoorMusic = "outdoor_music";
_levelCompletedMusic = "finish_level";
_musicCueName = _outdoorMusic;
_musicSoundGroup = @"data\sound\music";
_music = SoundManager.Instance.PlaySound(_musicSoundGroup, _outdoorMusic);
// play the dragon's startup sound for the first time
SoundManager.Instance.PlaySound(@"data\sound\dragon_grass.xsb", "startup");
}
#endregion
//game.cs
protected override void BeginRun()
{
base.BeginRun();
// go to splash screen
GUIUtil.InitGUIScreens("PlatformerDemo.UI");
GUIStyle splashStyle = new GUIStyle();
GUISceneview splash = new GUISceneview();
splash.Style = splashStyle;
GUICanvas.Instance.SetContentControl("SplashScreen");
// load the test level
SceneLoader.Load(@"data\levels\my_level_26.txscene");
// set the parallax manager's target object
T2DSceneCamera camera = T2DSceneGraph.Instance.Camera as T2DSceneCamera;
ParallaxManager.Instance.ParallaxTarget = camera;
// create game gui
GUIStyle playStyle = new GUIStyle();
GUISceneview play = new GUISceneview();
play.Name = "PlayScreen";
play.Style = playStyle;
GUICanvas.Instance.SetContentControl(play);
PlatformerDemoGUI.Instance.GUI.Folder = GUICanvas.Instance;
// register sound groups
SoundManager.Instance.RegisterSoundGroup(@"data\sound\music");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\general");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\drill");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\dragon_dirt.xsb", @"data\sound\dragon.xwb");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\dragon_grass.xsb", @"data\sound\dragon.xwb");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\dragon_wood.xsb", @"data\sound\dragon.xwb");
// grab the sound categories
_soundEffectsCategory = Engine.SFXDevice.GetCategory("Default");
_musicCategory = Engine.SFXDevice.GetCategory("Music");
// game start
_gameStart = Time;
// start music loop
_indoorMusic = "indoor_music";
_outdoorMusic = "outdoor_music";
_levelCompletedMusic = "finish_level";
_musicCueName = _outdoorMusic;
_musicSoundGroup = @"data\sound\music";
_music = SoundManager.Instance.PlaySound(_musicSoundGroup, _outdoorMusic);
// play the dragon's startup sound for the first time
SoundManager.Instance.PlaySound(@"data\sound\dragon_grass.xsb", "startup");
}
#endregion
Torque Owner Temasek Polytechnic (#0001)
//SplashScreen.cs
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.Sim;
using GarageGames.Torque.GUI;
using GarageGames.Torque.MathUtil;
using GarageGames.Torque.T2D;
namespace GarageGames.Torque.PlatformerDemo
{
class SplashScreen : GUISplash, IGUIScreen
{
//======================================================
#region Constructors
public SplashScreen()
{
// create the Style for our splash ad
GUISplashStyle splashStyle = new GUISplashStyle();
splashStyle.FadeInSec = 2; // black to image 2 seconds
splashStyle.FadeOutSec = 2; // image to black 2 seconds
splashStyle.FadeWaitSec = 4; // still image for 4 seconds
splashStyle.Bitmap = @"data\images\nice";
splashStyle.PreserveAspectRatio = true;
//splashStyle.Anchor = AnchorFlags.All;
// set some info for this control
Name = "SplashScreen";
Style = splashStyle;
Size = new SizeF(800, 600); // Changed System.Drawing.SizeF to Microsoft.Xna.Vector2
//(new (1024.0f, 768.0f));
OnFadeFinished = OnSplashFinished;
// create a black letterbox
// only visible on widescreen displays
GUIStyle lbStyle = new GUIStyle();
lbStyle.IsOpaque = true;
lbStyle.FillColor = Color.Black;
GUIControl letterbox = new GUIControl();
letterbox.Style = lbStyle;
GUICanvas.Instance.LetterBoxControl = letterbox;
}
#endregion
//======================================================
#region Public methods
///
/// Callback from the Splashscreen when the splash has finished fading.
///
public void OnSplashFinished()
{
//SceneLoader.Load(@"data\levels\my_level_26.txscene");
PlatformerDemo.Game.Instance.SceneLoader.Load(@"data\levels\my_level_26.txscene");
GUIStyle playStyle = new GUIStyle();
GUISceneview play = new GUISceneview();
play.Name = "PlayScreen";
play.Style = playStyle;
GUICanvas.Instance.SetContentControl(play);
PlatformerDemoGUI.Instance.GUI.Folder = GUICanvas.Instance;
}
#endregion
}
}