Game Development Community

Splash Screen problems

by Matthew Hoesterey · in Torque X 2D · 11/10/2007 (2:53 am) · 3 replies

Hello I'm using the Platformer starter kit and am having trouble getting anything UI to work I followed the tutorial but no luck. Any help would be great! I'm getting this error: PlatformerDemoGUI does not exist in the current context, I know that means it isn't defined in the class but I have no clue what that variable is suposed to be :( Here is my code:

// game.cs: code
using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;

using GarageGames.Torque.Core;
using GarageGames.Torque.Core.Xml;
using GarageGames.Torque.SceneGraph;
using GarageGames.Torque.Sim;
using GarageGames.Torque.GameUtil;
using GarageGames.Torque.GUI;
using GarageGames.Torque.T2D;
using GarageGames.Torque.Platform;
using GarageGames.Torque.Util;
using GarageGames.Torque.XNA;

using GarageGames.Torque.PlatformerFramework;

namespace PlatformerStarter
{
class Game : TorqueGame
{
//======================================================
#region Static methods, fields, constructors

public static Game Instance
{
get { return _game as Game; }
}

static TorqueGame _game;

#endregion

//======================================================
#region Constructors

public Game()
{
Assert.Fatal(_game == null, "doh");
_game = this;
_random = new Random();
}

#endregion

//======================================================
#region Public properties, operators, constants, and enums

public Random Random
{
get { return _random; }
}

public float Time
{
get { return totalTime; }
}

public float GameStart
{
get { return _gameStart; }
}

public List Players
{
get { return _players; }
}

#endregion

//======================================================
#region Private, protected, internal methods

protected override void SetupEngineComponent()
{
base.SetupEngineComponent();

// register the platformer framework with the engine component, so that we can load its types from XML
base._engineComponent.RegisterAssembly(typeof(PlatformerData).Assembly);
}

protected override void Update(GameTime gameTime)
{
base.Update(gameTime);

totalTime += gameTime.ElapsedGameTime.Milliseconds;
}

protected override void BeginRun()
{
base.BeginRun();
// go to splash screen
GUIUtil.InitGUIScreens("Starter.UI");
GUIStyle splashStyle = new GUIStyle();
GUISceneview splash = new GUISceneview();
splash.Style = splashStyle;
GUICanvas.Instance.SetContentControl("SplashScreen");

// load the test level
//SceneLoader.Load(@"data\levels\vs_level_sandbox.txscene");

// create game gui
//GUIStyle playStyle = new GUIStyle();
//GUISceneview play = new GUISceneview();
//play.Name = "PlayScreen";
// play.Style = playStyle;
// GUICanvas.Instance.SetContentControl("SplashScreenGUI");

// game start
_gameStart = Time;
}

#endregion

//======================================================
#region Private, protected, internal fields

Random _random;
float totalTime;
float _gameStart;
List _players = new List();

#endregion
}
}

#1
11/10/2007 (2:53 am)
//and the splash screen code:

#region Using Statements
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;
using GarageGames.Torque.PlatformerFramework;
//using TorqueCombat.Canvas;
#endregion

namespace StarterGame.UI
{
///
/// Displays the splash ad for TankBuster, first GUI screen to become visible.
///

public 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\GUI\Splash";
splashStyle.PreserveAspectRatio = true;
//splashStyle.Anchor = AnchorFlags.All;

// set some info for this control
Name = "SplashScreen";
Style = splashStyle;
Size = new SizeF(800, 600);
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()
{
//Load the txscene level file
// SceneLoader.Load(@"data\levels\vs_level_sandbox.txscene"); //Replace this with your own level loading code

PlatformerStarter.Game.Instance.SceneLoader.Load(@"data\levels\vs_level_sandbox.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
}
}



Thanks again for any help :)
#2
11/10/2007 (7:16 am)
(Note: Total XNA Newb here so fact checking would be in order from a 3rd party here)
From the looks of it, it would be of type GUICanvas since you want to change the member data at PlatformerDemoGUI.Instance.GUI.Folder.

But if you set it like this...
GUICanvas PlatformerDemoGUI.Instance.GUI.Folder = GUICanvas.Instance;
... you are trying to set the GUI.Folder ( a member of GUICanvas.Instance.GUI to the instance of GUICanvas.

Try setting PlatformerDemoGUI first and then point to the Folder once created. Something like...

GUICanvas PlatformerDemoGUI = new GUICanvas ();
PlatformerDemoGUI.Instance.GUI.Folder = GUICanvas.Instance.GUI.Folder;

... however I believe you are creating a new object, but pointing to the original objects folder this way. You probably want to do a deep copy if you want your new UI to be unique. Being a XNA newb, it is possible it has already done a deep copy on instantiation.
#3
11/10/2007 (10:09 am)
Gar that dosn't seem to be working. :(