mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
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:
@@ -74,6 +74,7 @@ New features:
|
||||
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value, or '-400'.
|
||||
* Buttons now properly use their upFrame if set.
|
||||
* InputHandler now has snapOffsetX and snapOffsetY properties so your snap grid doesn't have to be 0,0 aligned (thanks srmeier)
|
||||
* 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.
|
||||
|
||||
|
||||
New Examples:
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('ball', 'assets/sprites/shinyball.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var particles = [];
|
||||
var bmd;
|
||||
|
||||
var u = 0;
|
||||
var n = 0;
|
||||
var oldn = 0;
|
||||
var ad = 0;
|
||||
|
||||
function create() {
|
||||
|
||||
bmd = game.add.bitmapData(640, 480);
|
||||
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
particles.push(new Phaser.Point(0, 0));
|
||||
}
|
||||
|
||||
sprite = game.add.sprite(0, 0, bmd);
|
||||
|
||||
}
|
||||
|
||||
function mycircle(context, x, y, R, color) {
|
||||
|
||||
context.fillStyle = color;
|
||||
context.beginPath();
|
||||
context.arc(x, y, R, 0, Math.PI * 2, true);
|
||||
context.closePath();
|
||||
context.fill();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
bmd.clear();
|
||||
|
||||
oldn = n;
|
||||
|
||||
for (var t = 0; t < particles.length; t++)
|
||||
{
|
||||
var p = particles[t];
|
||||
|
||||
p.x = Math.sin(n) * 50 + Math.cos(n * 1.5) * 200;
|
||||
p.y = Math.sin(n / 2) * 20 + Math.sin(n * 2) * 150;
|
||||
|
||||
var tx = p.x;
|
||||
var ty = p.y;
|
||||
|
||||
bmd.context.globalCompositeOperation = 'xor';
|
||||
|
||||
mycircle(bmd.context, p.x + 320, p.y + 240, Math.sin(t * 360 / particles.length / 2 * Math.PI / 180) * 60, 'rgba(255, 255, 255, 1)');
|
||||
|
||||
n += 0.1;
|
||||
|
||||
bmd.context.globalCompositeOperation = 'source-over';
|
||||
}
|
||||
|
||||
n = oldn + 0.03;
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
}
|
||||
+12
-3
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user