Splashscreen component download
by Gavin Beard · in Torque X 2D · 06/08/2009 (3:09 pm) · 2 replies
Hi all,
Have been playing with making a Splashscreen component that I could easily reuse within TX2D ( I guess it'd work with TX3D as well).
To use it, firstly download THIS and add it to your project.
Then in your game.cs in BeginRun for example use:
When we setup the new splash component we must make sure we pass the location of your splash images to the constructor.
SplashImage is the number of splash screen images you have, you need to save your images with filenames 1.png,2.png,3.png (or what ever file format you use), these are displayed in reverse order so 3.png would be the first displayed. FinishedFunction is a reference to the function you want to call when the splash is finished. so in my game.cs I have a function called quitGame that just ends the game, but typically you'd call a function to load your next level or menu screen.
Finally we call doSplash(); to start the screens fading.
I'm sure this isnt the most elegant way of doing it, but it works well. Any feedback welcome.
Have been playing with making a Splashscreen component that I could easily reuse within TX2D ( I guess it'd work with TX3D as well).
To use it, firstly download THIS and add it to your project.
Then in your game.cs in BeginRun for example use:
Components.SplashComponent splash = new Components.SplashComponent(AppDomain.CurrentDomain.BaseDirectory+"dataimages"); splash.SplashImage = 3; splash.FinishedFunction = quitGame; splash.doSplash();
When we setup the new splash component we must make sure we pass the location of your splash images to the constructor.
SplashImage is the number of splash screen images you have, you need to save your images with filenames 1.png,2.png,3.png (or what ever file format you use), these are displayed in reverse order so 3.png would be the first displayed. FinishedFunction is a reference to the function you want to call when the splash is finished. so in my game.cs I have a function called quitGame that just ends the game, but typically you'd call a function to load your next level or menu screen.
Finally we call doSplash(); to start the screens fading.
I'm sure this isnt the most elegant way of doing it, but it works well. Any feedback welcome.
#2
The splash needs to know the location of the images to be displayed so they can be loaded.
The constructor is the method called when the SplashComponent is created, i.e.
You could supply a similar path to your images to the imgPath property, either as a full path including drive, or just a relative path, such as:
Incidentally, if you're wondering about the @ sign, when at the beginning of a string, it means to ignore any escape sequences in it, which would otherwise be signaled by a backslash. Without it, to get a literal backslash you would have to use a \\ in the string, i.e. "data\\images\\".
07/07/2009 (10:41 pm)
@Randell:The splash needs to know the location of the images to be displayed so they can be loaded.
The constructor is the method called when the SplashComponent is created, i.e.
SplashComponent(AppDomain.CurrentDomain.BaseDirectory+"dataimages");The argument passed into it is the full path to the location of the running application (which comes from the AppDomain class) appended by a string which should really read @"data\images\" (with slashes). For some reason, postings in these forums seems to lose the backslash.
You could supply a similar path to your images to the imgPath property, either as a full path including drive, or just a relative path, such as:
splash.imgPath = @"data\images\";
Incidentally, if you're wondering about the @ sign, when at the beginning of a string, it means to ignore any escape sequences in it, which would otherwise be signaled by a backslash. Without it, to get a literal backslash you would have to use a \\ in the string, i.e. "data\\images\\".
Torque Owner Randell Heft
i get the errors on the get; set; part of your code, can you get an example as to how you would write the location of where the images are in the get; set; fashion?