While working on my latest project – Ninja Way – I struggled a bit to find a way to add a custom loading screen on the HTML5 version, made with Game Maker Studio.
I have to admit that it took me some time to understand it, because of the lack of documentation and probably mostly because I am not very familiar with JS. But in the end I made it work as I wanted, than I modified it a bit to be more “readable” and “user-friendly” to an average GM user.
So, here I am to share with anyone who needs it my modification, along with a brief tutorial on how to implement it in GameMaker.
With this extension and following this tutorial you will be able to create a simple but nice loading screen with customizable loading bar and also add and image by URL, so in case you will have ot update it in the future you just have to change the image uploaded on the internet without the need to re-export your games! Moreover, an advanced user could make further customization to have an even nicer screen.
- GameMaker: Studio Professional with HTML5 exporter.
- Any text/code editor (I suggest Notepad++)
- FMS Loading Screen extension.* (It will be also soon available in the brand new GameMaker Marketplace)
First open your GameMaker project and import the extension.
Right-click on the Extension folder, select Import extension and upload the FMS_Loading.gmez file you have found inside the .zip archive.
Now you will need to activate the custom loader in Game Settings, so double click on Global Game Settings, choose HTML5 tab and select FMS_Custom_Loading in the drop-down menu of Loading Bar Extension. In this window we can also upload an image in the Splash Screen section, it will be used as background in our loading screen. To activate it tick Use Splash Screen option. Confirm by clicking Ok and that’s all we have to do in GameMaker.
Locate the script: open your project’s folder (somthing like my_game_name.gmx), inside it you will see many folders, one of those is extension. Open it and open the subfolder named FMS_Loading_SCreen. Here we’ll find FMS_loading.js, this is what makes everything possible, and where we haveto make some editing. Open the js with your code editor (with Notepad++ you just need to right click on it and select Edit with Notepad++)
Here we are, starting from line n.20 of our script we find a series of variable we can set to decide how the Loading Screen will look like.
The first part is about the text that will appear while loading, here we can set:
- The actual text that will be written
- Text style: pixel dimension and font
- Text alignment: Center, left, right
- Text color in rgb
- Text orizontal position (in pixel, from the left side)
- Text vertical position (in pixel, from the top)
The second section is about the loading bar. Let’s set:
- Width of the bar (in pixel)
- Height of the bar (in pixel)
- Loading bar orizontal position (in pixel, from the left side)
- Loading bar vertical position (in pixel, from the top)
- Bar border (in pixel)
- Bar border color
- Color of the background of the bar (that shows the part not yet loaded)
- Color of the progress bar (that shows the part already loaded)
Now we can specify some settings for the background of our screen and of the splash screen image we have set in GameMaker:
- Background color (visible in case image is not set or if it’s smaller than canvas)
- Loading Screen image height in pixel
- Loading Screen image width in pixel
- Loading Screen image vertical position (in pixel, from the top)
- Loading Screen image orizontal position (in pixel, from the left side)
I wanted to add a little feature: the ability to set an image from url instead of (OR ADDITIONALLY TO) the one set in GameMaker. Please not that if you have set both Splash Screen image in GameMaker and the custom image from URL, the latter will be placed ABOVE the one from GM, if bigger or same dimension it will cover it but if smaller it will be shown together!
In the fourth part of variable settings we can specify some parameters:
- URL to the image, if you don’t need it just leave empty quotes
- Custom image height in pixel
- Custom image width in pixel
- Custom image vertical position (in pixel, from the top)
- Custom image orizontal position (in pixel, from the left side)
Loading Screen Example
Note that there are a couple of confortable variables we can use and play with to help use with positioning and dimensions. they are _width and _height, in this var there are stored canvas width and canvas height. So it will be fast and easy to place something centerd for example, just like I did with text simply by setting
var text_x_pos= (_width/2);
There is no need of editing anything else, unless you know a bit of scripting and want to try something more advanced. There are comments on every functions so it’s quite easy to understan who does what.
When you are ready editing, simply run the game to see how your loading screen looks like!
*FMS_Loading_screen extension is a modification of Mike’s (YoYo Games) HTML5_Custom_Loading_Bar Extension.