Loader.progressFloat contains the actual non-rounded progress value, where-as Loader.progress contains a rounded value. Use progressFloat if you've > 100 files to load.

This commit is contained in:
photonstorm
2013-12-31 17:35:40 +00:00
parent d1cd1df9a5
commit 902ffee808
3 changed files with 86 additions and 3 deletions
+12 -3
View File
@@ -34,7 +34,7 @@ Phaser.Loader = function (game) {
this._fileIndex = 0;
/**
* @property {number} _progressChunk - Indicates assets loading progress. (from 0 to 100)
* @property {number} _progressChunk - Indicates the size of 1 file in terms of a percentage out of 100.
* @private
* @default
*/
@@ -59,11 +59,17 @@ Phaser.Loader = function (game) {
this.hasLoaded = false;
/**
* @property {number} progress - The Load progress percentage value (from 0 to 100)
* @property {number} progress - The rounded load progress percentage value (from 0 to 100)
* @default
*/
this.progress = 0;
/**
* @property {number} progressFloat - The non-rounded load progress value (from 0.0 to 100.0)
* @default
*/
this.progressFloat = 0;
/**
* You can optionally link a sprite to the preloader.
* If you do so the Sprite's width or height will be cropped based on the percentage loaded.
@@ -713,6 +719,7 @@ Phaser.Loader.prototype = {
}
this.progress = 0;
this.progressFloat = 0;
this.hasLoaded = false;
this.isLoading = true;
@@ -727,6 +734,7 @@ Phaser.Loader.prototype = {
else
{
this.progress = 100;
this.progressFloat = 100;
this.hasLoaded = true;
this.onLoadComplete.dispatch();
}
@@ -1217,7 +1225,8 @@ Phaser.Loader.prototype = {
*/
nextFile: function (previousIndex, success) {
this.progress = Math.round(this.progress + this._progressChunk);
this.progressFloat += this._progressChunk;
this.progress = Math.round(this.progressFloat);
if (this.progress > 100)
{