Utility object to be used while the game is loading. The LoadingScreen object has the ability to draw a texture in the middle of the screen surrounded by a solid color. If provided with the necessary information, it will also render a loading progress bar to visually depict loading progress of requested assets.
It can fade in and out smoothly if requested.
Required scripts
The LoadingScreen object requires:
/*{{ javascript("jslib/assettracker.js") }}*/
/*{{ javascript("jslib/loadingscreen.js") }}*/
Summary
Creates the LoadingScreen object using data from a parameter object.
If the parameter object is not specified, default values will be used and the loading progress bar will not be rendered.
All color fields are in RGBA format.
Syntax
var loadingScreenParameters = {
backgroundColor : mathDevice.v4Build (1, 1, 1, 1),
barColor : mathDevice.v4Build (1, 1, 0, 1),
barCenter : {x : 0.5, y : 0.5},
barBorderSize : 4,
barBackgroundColor : mathDevice.v4Build (0, 0, 1, 1),
barBackgroundHeight : 24,
barBackgroundWidth : 540,
assetTracker : trackingObject
};
var loadingScreen = LoadingScreen.create(graphicsDevice, mathDevice, loadingScreenParameters);
An object used to count the number of assets loaded and to perform the loading progress calculation. If this field is not specified, the progress loading bar will not be rendered.
For more information, see AssetTracker object.
Summary
Using this method, the loading screen would request for the texture specified and set it once the texture has been downloaded.
Syntax
loadingScreen.loadAndSetTexture(graphicsDevice, requestHandler, mappingTable, textureName);
Summary
Syntax
loadingScreen.setTexture(texture);
Summary
Adjust the alpha values of the background and texture. Useful for producing a fade effect from the loading screen to the game.
Syntax
loadingScreen.render(backgroundAlpha, textureAlpha);