Game Development Community

how do you script a GUI control to use as a splash screen

by hbomega · in Torque 2D Beginner · 08/12/2013 (1:19 pm) · 48 replies

having problems creating some splash screens, i tried Yahya,s solution and ended up with a problem " SimObject::deleteObject: Object is being deleted whilst performing a script callback " i know what this means but i have no clue how to fix it, so i decided to go with Steve Acaster solution except its outdated and i have no idea how to create the .gui files without the GUI Editor. i know it can be done by script i would like an example of how you would go about creating Gui Controls that can be used for splash Screens from script thanks

i keep getting

pushDialog(): Invalid control: Custom_StartupGui_Background
pushDialog(): Invalid control: Custom_StartupGui_Game
popDialog(): Invalid control: Custom_StartupGui_Game
pushDialog(): Invalid control: Custom_StartupGui_Developer
popDialog(): Invalid control: Custom_StartupGui_Developer
pushDialog(): Invalid control: Custom_StartupGui_Torque
popDialog(): Invalid control: Custom_StartupGui_Torque
popDialog(): Invalid control: Custom_StartupGui_Background

help please someone :(
#21
08/14/2013 (7:15 am)
Do you have spaces in that line?

@asset = MyModule:logo1

Make sure there are no spaces between @asset, =, and MyModule:logo1.
#22
08/14/2013 (7:18 am)
i did but i already cleared them up, one thing the logo's are in the jpg format could that be causing the problem
#23
08/14/2013 (7:25 am)
JPG files are fine. Could you post your MyModule module definition and your logo1 asset definition? My guess is one of those are wrong.
#24
08/14/2013 (7:27 am)
Also, open the main.cs in the root directory (where Torque2D.exe is located). You will see two lines:

// Set module database information echo.
ModuleDatabase.EchoInfo = false;

// Set asset database information echo.
AssetDatabase.EchoInfo = false;

Change each false to true. This will generate a lot more console output, but it should pinpoint problems with your TAML files for modules and assets.
#25
08/14/2013 (7:33 am)
MyModule:

<ModuleDefinition
ModuleId="MyModule"
VersionId="1"
Dependencies="ToyAssets=1"
ScriptFile="main.cs"
CreateFunction="create"
DestroyFunction="destroy" >

<DeclaredAssets
Path="assets"
Extension="asset.taml"
Recurse="true"/>

</ModuleDefinition>

logo1:

<ImageAsset
AssetName="logo1"
ImageFile="logo1.jpg" />
#26
08/14/2013 (7:46 am)
Ok. Your console log is going to be too large for our website. After you enable those variables to true, copy and paste the contents of your console.log file to pastebin.
#27
08/14/2013 (7:58 am)
Asset Manager: ... Finished scanning for declared assets in path 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/ToyAssets/1/assets' for files with extension 'asset.taml'.
--------------------------------------------------------------------------------

Adding path expando of 'MyModule' as 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule'.
--------------------------------------------------------------------------------
Asset Manager: Scanning for declared assets in path 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/Asset' for files with extension 'asset.taml'...
--------------------------------------------------------------------------------
Asset Manager: Adding Asset Id 'MyModule:PowerBall' of type 'ImageAsset' in asset file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/PowerBall.asset.taml'.
--------------------------------------------------------------------------------
Asset Manager: Adding Asset Id 'MyModule:sky1Background' of type 'ImageAsset' in asset file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/sky1Background.asset.taml'.
--------------------------------------------------------------------------------
Asset Manager: Adding Asset Id 'MyModule:logo1' of type 'ImageAsset' in asset file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/splash/logo1.asset.taml'.
--------------------------------------------------------------------------------
Asset Manager: Adding Asset Id 'MyModule:logo2' of type 'ImageAsset' in asset file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/splash/logo2.asset.taml'.
--------------------------------------------------------------------------------
Asset Manager: Adding Asset Id 'MyModule:logo3' of type 'ImageAsset' in asset file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/splash/logo3.asset.taml'.
--------------------------------------------------------------------------------
Asset Manager: ... Finished scanning for declared assets in path 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/Asset' for files with extension 'asset.taml'.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Asset Manager: Started acquiring Asset Id 'MyModule:logo1'...
Asset Manager: > Loading asset into memory as object Id '1121' from file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/splash/logo1.asset.taml'.
Asset Manager: > Finished acquiring asset. Reference count now '1'.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Asset Manager: Started releasing Asset Id 'MyModule:logo1'...
Asset Manager: > Releasing to idle state.
Asset Manager: > Finished releasing Asset Id 'MyModule:logo1'.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Asset Manager: Started acquiring Asset Id 'MyModule:sky1Background'...
Asset Manager: > Loading asset into memory as object Id '1131' from file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/sky1Background.asset.taml'.
Asset Manager: > Finished acquiring asset. Reference count now '1'.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Asset Manager: Started acquiring Asset Id 'myModule:PowerBall'...
Asset Manager: > Loading asset into memory as object Id '1133' from file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/MyModule/asset/PowerBall.asset.taml'.
Asset Manager: > Finished acquiring asset. Reference count now '1'.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Asset Manager: Started acquiring Asset Id 'myModule:PowerBall'...
Asset Manager: > Finished acquiring asset. Reference count now '2'.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Asset Manager: Started acquiring Asset Id 'ToyAssets:Font'...
Asset Manager: > Loading asset into memory as object Id '1136' from file 'C:/Users/HBOMEGA/Documents/Torque 2D/Alien Blast v1/modules/ToyAssets/1/assets/images/font.asset.taml'.
Asset Manager: > Finished acquiring asset. Reference count now '1'.
--------------------------------------------------------------------------------
#28
08/14/2013 (8:00 am)
sorry got it late will copy to pastebin
#29
08/14/2013 (8:06 am)
done its on pastebin
#30
08/14/2013 (8:06 am)
I see a problem. Look at this bold part:

<ModuleDefinition
ModuleId="MyModule"
VersionId="1"
Dependencies="ToyAssets=1"
ScriptFile="main.cs"
CreateFunction="create"
DestroyFunction="destroy" >

<DeclaredAssets
Path="assets"
Extension="asset.taml"
Recurse="true"/>

</ModuleDefinition>

Yet, you are storing your stuff in a folder named asset. You are missing an 's' in your folder. Either rename the folder or update your module path to be "asset".
#31
08/14/2013 (8:22 am)
i realized that and changed it but my problem is still there

i made sure the asset folder was spelled "asset" and changed
Path="assets" to Path="asset" no luck
#32
08/14/2013 (8:24 am)
Ok. Copy and paste your entire console log to a new pastebin. Make sure you post a link to the pastebin you created here in the thread. I can't find it out with your link.
#33
08/14/2013 (8:39 am)
http://pastebin.com/vAnQ7UNq
#34
08/14/2013 (8:42 am)
also is all the assets in Sandbox free to use even in commercial products
#35
08/14/2013 (9:04 am)
Alright, I'm reading the log now and will let you know if I spot something. As for the assets in the repository, those are all free for you to use in commercial products. Whether it's GUI art, sprites, or data, you can use it.
#36
08/14/2013 (9:06 am)
Your latest console output appears to be error free. No warnings or messages regarding logo1. So it seems we are back to trying to figure out script logic, as all data seems to check out. Is that what you are seeing in your project now?
#37
08/14/2013 (9:22 am)
yes thats what i see in my projects now, however i think there might be a problem with the piece of code you mentioned earlier

//-----------------------------------------------------------------------------
// StartupGui is the splash screen that initially shows when the game is loaded
//-----------------------------------------------------------------------------

function loadStartup()
{
//called from init.cs
Canvas.pushDialog(Custom_StartupGui_Background);//load the background
schedule(5000, 0, "Load_Startup_Back_Done");//schedule the game screen
}

function Load_Startup_Back_Done()
{
Canvas.pushDialog(Custom_StartupGui_Game);//display the Game screen
schedule(3000, 0, "Load_Startup_Game_Done");//schedule the Developer/company screen
}

function Load_Startup_Game_Done()
{
Canvas.popDialog(Custom_StartupGui_Game);//unload the Game screen
Canvas.pushDialog(Custom_StartupGui_Developer);//display the Developer/Company screen
schedule(2000, 0, "Load_Startup_Developer_Done");//schedule the Torque screen
}

function Load_Startup_Developer_Done()
{
Canvas.popDialog(Custom_StartupGui_Developer);//unload the Developer/Company screen
Canvas.pushDialog(Custom_StartupGui_Torque);//display the Torque logo
schedule(5500, 0, "StartupGui_onDone");//schedule the end of startup and display the main menu
//if you're using the stock fade gui element +1500 on 4 seconds for last screen to fade out
//it takes a little longer for this one or Main Menu kicks in a bit fast
//and the result it visually jarring - just a word of warning ...
}

function StartupGui_onDone(%this)
{
Canvas.popDialog(Custom_StartupGui_Torque);//unload the Torque logo
Canvas.popDialog(Custom_StartupGui_Background);//unload the background

//loadMainMenu();//load the main menu and lets play games!
mySceneWindow.setScene(SceneW1S1);

}


It doesn't go to SceneW1S1 it just shows the scene that i call from main SceneW1S2 and stays there
#38
08/14/2013 (9:33 am)
At this point, it's tough to tell what's happening without actually debugging the code myself. Here are some questions to get us further:

1. Do you make it into StartupGui_onDone()? Are Custom_StartupGui_Torque and Custom_StartupGui_Background being popped?

2. Where is mySceneWindow defined and pushed?

3. Where is SceneW1S1 defined and being loaded?
#39
08/14/2013 (11:07 am)
no it doe not make it to StartupGui_onDone()
Custom_StartupGui_Torque and Custom_StartupGui_Background are not being popped

2: mySceneWindow is defined in scenewindow.cs, and exec in main.cs

3: SceneW1S1 is defined in scenew1s1.cs, and exec in main.cs and also loaded in main.cs

would you like me to paste my main.cs file on pastebin
#40
08/14/2013 (11:09 am)
Ignore my last post #39 i'm resending info now