mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Fixed the Loader.preloadSprite crop effect on WebGL.
This commit is contained in:
parent
a7ff5f884c
commit
870d534e50
2 changed files with 13 additions and 10 deletions
|
@ -67,6 +67,7 @@ Bug Fixes
|
|||
* Removed the examples build script from the Gruntfile (fix #592)
|
||||
* The P2 World wouldn't clear down fully on a State change, now properly clears out contacts, resets the bitmask, etc.
|
||||
* Button.onInputUpHandler wouldn't set an upFrame for a frame ID of zero, made the check more strict.
|
||||
* Fixed the Loader.preloadSprite crop effect on WebGL.
|
||||
|
||||
|
||||
Updated:
|
||||
|
|
|
@ -147,27 +147,27 @@ Phaser.Loader.prototype = {
|
|||
* This allows you to easily make loading bars for games. Note that Sprite.visible = true will be set when calling this.
|
||||
*
|
||||
* @method Phaser.Loader#setPreloadSprite
|
||||
* @param {Phaser.Sprite|Phaser.Image} sprite - The sprite that will be cropped during the load.
|
||||
* @param {number} [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped.
|
||||
* @param {Phaser.Sprite|Phaser.Image} sprite - The sprite or image that will be cropped during the load.
|
||||
* @param {number} [direction=0] - A value of zero means the sprite will be cropped horizontally, a value of 1 means its will be cropped vertically.
|
||||
*/
|
||||
setPreloadSprite: function (sprite, direction) {
|
||||
|
||||
direction = direction || 0;
|
||||
|
||||
this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, crop: null };
|
||||
this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, rect: null };
|
||||
|
||||
if (direction === 0)
|
||||
{
|
||||
// Horizontal crop
|
||||
this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 1, sprite.height);
|
||||
// Horizontal rect
|
||||
this.preloadSprite.rect = new Phaser.Rectangle(0, 0, 1, sprite.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Vertical crop
|
||||
this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 1);
|
||||
// Vertical rect
|
||||
this.preloadSprite.rect = new Phaser.Rectangle(0, 0, sprite.width, 1);
|
||||
}
|
||||
|
||||
sprite.crop(this.preloadSprite.crop);
|
||||
sprite.crop(this.preloadSprite.rect);
|
||||
|
||||
sprite.visible = true;
|
||||
|
||||
|
@ -1381,11 +1381,13 @@ Phaser.Loader.prototype = {
|
|||
{
|
||||
if (this.preloadSprite.direction === 0)
|
||||
{
|
||||
this.preloadSprite.crop.width = Math.floor((this.preloadSprite.width / 100) * this.progress);
|
||||
this.preloadSprite.rect.width = Math.floor((this.preloadSprite.width / 100) * this.progress);
|
||||
this.preloadSprite.sprite.crop(this.preloadSprite.rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.preloadSprite.crop.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
|
||||
this.preloadSprite.rect.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
|
||||
this.preloadSprite.sprite.crop(this.preloadSprite.rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue