Game Development Community

A GUI problem that I have

by Andre Mercier · in Torque 2D Beginner · 07/12/2013 (7:36 pm) · 12 replies

Hello, I have a problem with the getting started chapter 6, the GUI one. I went through the getting started tutorial and I followed every other chapters and did what it says in each one. The problem for me in chapter 6 is the part with the GuiControls. I don't know if there's a default GuiControl code that I can put with the new empty GUIProfile. I looked at the Sandbox module and I tried to understand what I need to put in mine but unfortunately I don't understand. Currently, thats the problem I'm facing because when I open up the .exe file in myT2DProject folder, it gives me an error about that GUI thing.

#1
07/13/2013 (3:29 am)
Hi Andre,

To better help you - what kind of error are you getting exactly?

In the Getting Started tutorial, the GuiProfile you make in Chapter 6 is for the SceneWindow in Chapter 7. (A SceneWindow is a GuiControl). So perhaps there is an issue in your script linking the SceneWindow to the GuiProfile?
#2
07/13/2013 (7:11 am)
The error I get when I open up the .exe is that the "GuiControlProfile: Unable to find specified profile (GuiDefaultProfile) and GuiDefault Profile does not exist!"

So are the following chapters about SceneWindow, Scene, and SceneObject are GuiControls that I have to put in the code in Chapter 6?
#3
07/13/2013 (7:31 am)
Only the SceneWindow is a GuiControl. Scene and SceneObject belong to different engine classes.

Based on the error message you got, did you forget to load the guiProfiles.cs file?

It is this step:

In /myModule/main.cs, add the following code in the MyModule::create function

// Load GUI profiles.
  exec("./gui/guiProfiles.cs");
#4
07/13/2013 (5:56 pm)
Yes, I have exec("./gui/guiProfiles.cs"); in my main.cs in the MyModule::create function.

All I have in the guiProfiles.cs is:

if(!isObject(GuiDefaultProfile)) new GuiControlProfile (GuiDefault Profile);

Do I have to write the SceneWindow code in this .cs file or what do I need to add to this?
#5
07/14/2013 (4:01 am)
According to the tutorial, you only need that 1 line in guiProfiles.cs. The SceneWindow code is written in a separate script file. The SceneWindow gets linked to the profile in this line of code from Chapter 7:

// Set Gui profile. If you omit the following line, the program will still run as it uses                
// GuiDefaultProfile by default

mySceneWindow.Profile = GuiDefaultProfile;

Looking at the line of code you wrote in your last post - is there a space between Default and Profile? It should be written all as one word: GuiDefaultProfile
#6
07/14/2013 (6:56 am)
I wrote that in the scenewindow.cs and I went over both Chapter 6 and 7 to see what I missed but it doesn't look like I'm missing anything. Unfortunately, I don't see why it gives me this error. There was a space and I fixed that. Thank You.

There's another error window that popped up:

GuiControl: mySceneWindow created with no profile



#7
07/14/2013 (7:40 am)
Maybe it would be easier if you could copy and paste the contents of your guiProfiles.cs and sceneWindow.cs to a post here. It sounds like you might just have a typo somewhere.
#8
07/14/2013 (9:28 am)
Here's the GuiProfile.cs:

if(!isObject(GuiDefaultProfile)) new GuiControlProfile (GuiDefaultProfile);



Here's the sceneWindow.cs:

function createSceneWindow()
{
//Sanity
if(!isObject(mySceneWindow) )
{
//Create the scene window.
new SceneWindow(mySceneWindow);

//Set Gui profile. If you omit the following
//line, the program will still run as it uses
//GuiDefaultProfile by default

mySceneWindow.Profile = GuiDefaultProfile;

//Place the sceneWindow on the Canvas
Canvas.setContent(mySceneWindow);
}

//Note that the SceneWindow's Camera defaults to
//the follwing values, you could omit them entirely and
//obtain the same result.

mySceneWindow.setCameraPosition(0,0);
mySceneWindow.setCameraSize(100, 75);
mySceneWindow.setCameraZoom(1);
mySceneWindow.setCameraAngle(0);

}

function destroySceneWindow()
{
//Finish if no window available.
if(!isObject(mySceneWindow) )
return;

//Delete the window.
mySceneWindow.delete();

}
#9
07/14/2013 (11:27 am)
Hmm, everything looks ok in those two files. The only other thing I can think of is you might have things out of order in the create function of the main.cs file. Could you post that please?
#10
07/14/2013 (2:05 pm)
Sure. Here it is:

function MyModule::create(%this)
{
//Load GUI profiles
exec("./gui/guiProfiles.cs");
exec("./scripts/scenewindow.cs");
createSceneWindow();
exec("./scripts/scene.cs");
createScene();
mySceneWindow.setScene(myScene);
createBackground();
createSpaceShip();
createAsteroids(20);
InputManager.Init_controls();
}

function MyModule::destroy(%this)
{
shipcontrols.pop();
destroySceneWindow();
}

#11
07/17/2013 (5:24 am)
Maybe put all the exec lines together before everything else. I had a similar problem when I did it I think.
#12
07/17/2013 (11:02 pm)
My friend has found the problem in the main.cs. I have the exec lines together now. The problem was that the pathway in guiProfile was wrong. I'm able to open up the .exe file and it shows just a blank blue screen. Where exactly do I put the myScene.add(MySceneObject)?