1.0.4 release

This commit is contained in:
Richard Davey
2013-09-18 06:34:56 +01:00
parent a102859622
commit d9a49797c4
15 changed files with 1071 additions and 728 deletions
+3 -3
View File
@@ -80,7 +80,7 @@ Phaser.Cache.prototype = {
*/
addRenderTexture: function (key, texture) {
var frame = new Phaser.Animation.Frame(0, 0, texture.width, texture.height, '', '');
var frame = new Phaser.Animation.Frame(0, 0, 0, texture.width, texture.height, '', '');
this._textures[key] = { texture: texture, frame: frame };
@@ -177,7 +177,7 @@ Phaser.Cache.prototype = {
addDefaultImage: function () {
this._images['__default'] = { url: null, data: null, spriteSheet: false };
this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 32, 32, '', '');
this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 0, 32, 32, '', '');
var base = new PIXI.BaseTexture();
base.width = 32;
@@ -198,7 +198,7 @@ Phaser.Cache.prototype = {
addImage: function (key, url, data) {
this._images[key] = { url: url, data: data, spriteSheet: false };
this._images[key].frame = new Phaser.Animation.Frame(0, 0, data.width, data.height, '', '');
this._images[key].frame = new Phaser.Animation.Frame(0, 0, 0, data.width, data.height, '', '');
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
+42
View File
@@ -57,6 +57,12 @@ Phaser.Loader = function (game) {
*/
this.progress = 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.
*/
this.preloadSprite = null;
/**
* The crossOrigin value applied to loaded images
* @type {string}
@@ -90,6 +96,27 @@ Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2;
Phaser.Loader.prototype = {
setPreloadSprite: function (sprite, direction) {
direction = direction || 0;
this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, crop: null };
if (direction == 0)
{
// Horizontal crop
this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 0, sprite.height);
}
else
{
// Vertical crop
this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 0);
}
sprite.crop = this.preloadSprite.crop;
},
/**
* Check whether asset exists with a specific key.
* @param key {string} Key of the asset you want to check.
@@ -113,6 +140,7 @@ Phaser.Loader.prototype = {
*/
reset: function () {
this.preloadSprite = null;
this.queueSize = 0;
this.isLoading = false;
@@ -872,6 +900,20 @@ Phaser.Loader.prototype = {
this.progress = 100;
}
if (this.preloadSprite !== null)
{
if (this.preloadSprite.direction == 0)
{
this.preloadSprite.crop.width = (this.preloadSprite.width / 100) * this.progress;
}
else
{
this.preloadSprite.crop.height = (this.preloadSprite.height / 100) * this.progress;
}
this.preloadSprite.sprite.crop = this.preloadSprite.crop;
}
this.onFileComplete.dispatch(this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize);
if (this._keys.length > 0)