Utility object that provides a means to count the number of assets loaded at start up during development. Once game startup requirements have been finalised, this information can then be used to calculate the loading progress as the game downloads its assets.
Summary
Creates the AssetTracker object.
This object can be used to determine the total number of assets that are loaded at startup.
By creating the the object using zero for the numberAssetsToLoad and true for the displayLog parameters, a log showing all the the names of the assets loaded and the count will be displayed in the console.
Once the total number of assets to load is known, the parameters for creating the object should then be modified.
Syntax
var assetTracker = AssetTracker.create(numberAssetsToLoad, displayLog);
Summary
This callback has to be registered on the ‘eventOnLoad’ event with the request handler being used for the game.
This callback is used to perform tracking of loaded assets and progress calculations.
It is called once per asset loaded.
Syntax
requestHandler.addEventListener('eventOnload', assetTracker.eventOnLoadHandler);
This callback has a single parameter which is passed to it when it is triggered.
Summary
Returns the number of assets loaded.
Syntax
var numberAssetsLoaded = assetTracker.getLoadedCount();
Summary
Returns the current loading progress, a number between 0 and 1 inclusive. When all the requested assets have been loaded, this value will be equal to 1.
Syntax
var loadingProgress = assetTracker.getLoadingProgress();
Summary
Sets a callback function for an action to take each time the assetTracker updates its values and calculations.
Syntax
assetTracker.setCallback(callback);