SplashScreen error
by Jin Shin · in Torque X 2D · 06/26/2009 (8:16 pm) · 7 replies
hello
i am following SplashScreen tutorial(http://tdn.garagegames.com/wiki/TorqueX/SplashScreen)
and in SplashScreen.cs
public void OnSplashFinished()
{
PlatformerStarter.Game.Instance.SceneLoader.Load(@"data\levels\sample_level.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;
}
i am getting this error
Quote:The name 'PlatformerDemoGUI' does not exist in the current context
also in Game.cs
base.BeginRun();
// go to splash screen
SplashScreen splashScreen = new SplashScreen();
GUIStyle splashStyle = new GUIStyle();
GUISceneview splash = new GUISceneview();
splash.Style = splashStyle;
GUICanvas.Instance.SetContentControl("SplashScreen");
I am getting this error as well
Quote:The type or namespace name 'SplashScreen' could not be found (are you missing a using directive or an assembly reference?)
My SplashScreen.cs is in the /Game directory and I'm not sure what else to try.
i am following SplashScreen tutorial(http://tdn.garagegames.com/wiki/TorqueX/SplashScreen)
and in SplashScreen.cs
public void OnSplashFinished()
{
PlatformerStarter.Game.Instance.SceneLoader.Load(@"data\levels\sample_level.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;
}
i am getting this error
Quote:The name 'PlatformerDemoGUI' does not exist in the current context
also in Game.cs
base.BeginRun();
// go to splash screen
SplashScreen splashScreen = new SplashScreen();
GUIStyle splashStyle = new GUIStyle();
GUISceneview splash = new GUISceneview();
splash.Style = splashStyle;
GUICanvas.Instance.SetContentControl("SplashScreen");
I am getting this error as well
Quote:The type or namespace name 'SplashScreen' could not be found (are you missing a using directive or an assembly reference?)
My SplashScreen.cs is in the /Game directory and I'm not sure what else to try.
#2
Now I don’t see build error anymore but problems is that level_01.txscene show without display splashscreen. I am not a programmer and even close to programming. Please give me detail helps. Thank you for your helping
Here is what I changed it from previous one
In SplashScreen.cs
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\test_splash";
splashStyle.PreserveAspectRatio = true;
//splashStyle.Anchor = AnchorFlags.All;
// set some info for this control
Name = "SplashScreen";
Style = splashStyle;
Size = new Vector2(800, 600); // Changed System.Drawing.SizeF to Microsoft.Xna.Vector2
//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;
}
#endregion
//======================================================
#region Public methods
/// <summary>
/// Callback from the Splashscreen when the splash has finished fading.
/// </summary>
public void OnSplashFinished()
{
//Load the txscene level file
PlatformerDemo.Game.Instance.SceneLoader.Load(@"data\levels\level_01.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
}
}
in game.cs
base.BeginRun();
// go to splash screen
SplashScreen splashScreen = new SplashScreen();
GUIStyle splashStyle = new GUIStyle();
GUISceneview splash = new GUISceneview();
splash.Style = splashStyle;
GUICanvas.Instance.SetContentControl("SplashScreen");
// load the test level
SceneLoader.Load(@"data\levels\level_01.txscene");
06/27/2009 (7:13 pm)
Hi,Now I don’t see build error anymore but problems is that level_01.txscene show without display splashscreen. I am not a programmer and even close to programming. Please give me detail helps. Thank you for your helping
Here is what I changed it from previous one
In SplashScreen.cs
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\test_splash";
splashStyle.PreserveAspectRatio = true;
//splashStyle.Anchor = AnchorFlags.All;
// set some info for this control
Name = "SplashScreen";
Style = splashStyle;
Size = new Vector2(800, 600); // Changed System.Drawing.SizeF to Microsoft.Xna.Vector2
//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;
}
#endregion
//======================================================
#region Public methods
/// <summary>
/// Callback from the Splashscreen when the splash has finished fading.
/// </summary>
public void OnSplashFinished()
{
//Load the txscene level file
PlatformerDemo.Game.Instance.SceneLoader.Load(@"data\levels\level_01.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
}
}
in game.cs
base.BeginRun();
// go to splash screen
SplashScreen splashScreen = new SplashScreen();
GUIStyle splashStyle = new GUIStyle();
GUISceneview splash = new GUISceneview();
splash.Style = splashStyle;
GUICanvas.Instance.SetContentControl("SplashScreen");
// load the test level
SceneLoader.Load(@"data\levels\level_01.txscene");
#3
And finally, it can be helpful when posting code to use the markup for it, i.e. tags before and after the code [code=c#][/code] that will format it like the lines above. See the MarkupLite Reference for more details.
06/28/2009 (12:03 pm)
Your code looks just about right. A few things:- You have the line OnFadeFinished = OnSplashFinished; commented out. That line needs to be used to have that method called when the splash is done.
- In the OnSplashFinished method, the lines that are commented out should be restored. I'm just not certain on what the class PlatformerDemoGUI looks like or is supposed to do. Would please you post the code of that class (whole file)?
- Since OnSplashFinished loads the scene, you should remove the line loading it after GUICanvas.Instance.SetContentControl("SplashScreen");.
- You also don't need the lines:
GUIStyle splashStyle = new GUIStyle(); GUISceneview splash = new GUISceneview(); splash.Style = splashStyle;
And finally, it can be helpful when posting code to use the markup for it, i.e. tags before and after the code [code=c#][/code] that will format it like the lines above. See the MarkupLite Reference for more details.
#4
I still couldn’t figure this out.
Here is whole code of SplashScreen.cs and Game.cs
I don’t see any error when I build them.
This is SplashScreen.cs
07/01/2009 (7:24 pm)
Hi ScottI still couldn’t figure this out.
Here is whole code of SplashScreen.cs and Game.cs
I don’t see any error when I build them.
This is SplashScreen.cs
#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.SceneGraph;
//using TorqueCombat.Canvas;
#endregion
namespace GarageGames.Torque.PlatformerDemo.UI
{
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 = @"dataimagestest_splash";
splashStyle.PreserveAspectRatio = true;
//splashStyle.Anchor = AnchorFlags.All;
// set some info for this control
Name = "SplashScreen";
Style = splashStyle;
Size = new Vector2(800, 600); // Changed System.Drawing.SizeF to Microsoft.Xna.Vector2
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;
}
#endregion
//======================================================
#region Public methods
public void OnSplashFinished()
{
//Load the txscene level file
PlatformerDemo.Game.Instance.SceneLoader.Load(@"datalevelslevel_01.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
}
}
#5
07/01/2009 (7:27 pm)
This is game.cs protected override void BeginRun()
{
base.BeginRun();
// go to splash screen
UI.SplashScreen splashScreen = new UI.SplashScreen();
GUICanvas.Instance.SetContentControl("SplashScreen");
// load the test level
SceneLoader.Load(@"data\levels\level_01.txscene");
// set the parallax manager's target object
T2DSceneCamera camera = TorqueObjectDatabase.Instance.FindObject<T2DSceneCamera>("Camera");
ParallaxManager.Instance.ParallaxTarget = camera;
_sceneGraph = camera.SceneGraph as T2DSceneGraph;
#6
Also, I would recommend putting the code to begin level 1 in a public method of Game. That would include loading the level, setting the GUICanvas content control and PlatformerDemoGUI, then whatever you're doing with ParallaxManager.
With all of that encapsulated in a method, all you need to do inside OnSplashFinished() is invoke that method through Game.Instance and the level should be good to go as soon as the splash is finished.
07/02/2009 (12:46 am)
One thing I'm seeing is your paths to the bitmap and scene are listed as dataimagestest_splash and datalevelslevel_01.txscene. I don't know if that was a result of the copy and paste, but they obviously need slashes like how you did in BeginRun().Also, I would recommend putting the code to begin level 1 in a public method of Game. That would include loading the level, setting the GUICanvas content control and PlatformerDemoGUI, then whatever you're doing with ParallaxManager.
With all of that encapsulated in a method, all you need to do inside OnSplashFinished() is invoke that method through Game.Instance and the level should be good to go as soon as the splash is finished.
#7
this might be your error,
the setcontentcontrol function takes a string
for example:
GUICanvas.Instance.SetContentControl("NameOfGuiScreen");
11/26/2009 (4:10 am)
GUICanvas.Instance.SetContentControl(play); this might be your error,
the setcontentcontrol function takes a string
for example:
GUICanvas.Instance.SetContentControl("NameOfGuiScreen");
Torque Owner Scott Zarnke
Perhaps "PlatformerStarter" is the namespace that PlatformerDemoGUI is in? Then it would be something like