Game Development Community

Torque2D wiki Getting started guide

by Aaron Miller · in Torque 2D Beginner · 03/13/2013 (12:56 am) · 4 replies

I've got a couple of questions about the getting started guide. First I'm wondering if anyone has gone through it step by step and gotten it to work. I noted there were some errors, a few which caused the example to fail, and I'm wondering if I'm just doing something wrong or if it's not fully operational yet.

First a few corrections:

Chapter 3. Project Planning and Basic Preparations
ModuleDatabse.loadExplicit("MyModule");

needs to be

ModuleDatabase.loadExplicit("MyModule");

or it won't load the user's created module at all.

Chapter 6. A primer on the Graphical User interface
Unless I'm doing something horribly wrong it looks like the line

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

will not work just by itself. It issues "Failed to load profile bitmap NULL." Using bitmap = ""; in the profile didn't work so I traced through GuiControlProfile::incRefCount() and found that it doesn't look like you can get away with not specifying a bitmap.
By comparison the Sandbox guiProfiles.cs file defines the GuiDefaultProfile with

bitmap = "^Sandbox/gui/images/window.png";

When I copied Sandbox/1/gui/window.png and made a similar folder in AppCore and put the window.png file there and changed the bitmap line to "^AppCore/gui/images/window.png"; it worked.

Also,
function createSceneWindow()
has the line

SandboxWindow.Profile = GuiDefaultProfile;

I think this should be mySceneWindow.Profile = GuiDefaultProfile; if I'm following the example right.

Chapter 7. Creating and using a SceneWindow
Probably a nitpick but "Under myModule/scripts, create a new file named 'scenewindow.cs'" should be
"myModule/1/scripts"


That's about as far as I've gotten because I can't get the window to go black from 'cornflowerblue.' I've turned on script tracing and checked the log as well as debugged a few of the Canvas calls to check the values:
*the sceneWindow.cs file is being exec'd
*createSceneWindow is being called
*mySceneWindow is a valid object
*the object passed into Canvas.setContent has GuiDefaultProfile as its profile
*I wasn't quite following mySceneWindow.setBackgroundColor("Black") in debug so I tried the setting RGB values ("0 0 0 255") and using mySceneWindow.getBackgroundColor(). The log shows it returns 0 0 0 255 and I can confirm the values are being set in code.

My thought is maybe the GuiDefaultProfile is borked, but I'm not sure how to test for that. Any ideas would be appreciated, I've been at this for awhile now and am setting it aside for the eve.




#1
03/13/2013 (3:31 am)
Aaron, good finds! I've fixed the typos which you've mentioned. You are correct in thinking that the guide is not finished, as I've written it as I went along with the coding, I have yet to re-code it from a blank slate.

- you are correct about Scenewindow returning "Failed to load profile bitmap NULL." Using bitmap = "";. However the scenewindow still renders on my test module. and works as expected. On that topic, I will change the guide to include a more complete GuiDefaultProfile so as to avoid this error.

Note that there will be several changes to the guide over the next few days, most notably changing the use of the myModule/1/ directory and the inclusion of a completed version of the tutorial as a .zip file for download.

On your last point, did you specifically call
mySceneWindow.setUseBackgroundColor(true);

I've made some tests and fail to replicate the issue.

#2
03/13/2013 (3:50 am)
Be aware that you don't need to do:
SandboxWindow.Profile = GuiDefaultProfile;
The SceneWindow type should work perfectly well without that. The only thing it uses it for is the debug-overlay rendering which is takes the font, background and foreground color for the text. If you don't specify it then it uses defaults.

It's only done in the Sandbox to choose these aspects.
#3
03/13/2013 (3:52 am)
The same goes for:
mySceneWindow.setBackgroundColor("Black");
mySceneWindow.setUseBackgroundColor(true);

It's not needed and results in most cases in clearing the background twice i.e the canvas clears it then the scene clears it (assuming it's fullscreen). On devices like the iPad, that's not good.
#4
03/13/2013 (10:27 am)
Thanks for the fast replies. I tried rebuilding my module from scratch, copy-pasting from the guide, and am still not getting the background to change to black, but I see that the wiki was amended to remove that step anyway (the part about "If you run your program now, your window should turn Black. If something went wrong with your SceneWindow setup, your program should still display its "CornFlowerBlue" background.") I can get the background and ship to display fine, so the sceneWindow must be ok-- I'd just stopped thinking it wasn't working because I couldn't get it to go black.

Incidentally, in AppCore's main.cs changing

Canvas.BackgroundColor = "Black";
Canvas.UseBackgroundColor = true;

changes the background color just fine. I'm pressed for time but will follow along further as the example as a whole seems to be working.