mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Hooked the Texture Manager into the Cache.
This commit is contained in:
parent
70729234e8
commit
e0ef9cab8b
2 changed files with 40 additions and 4 deletions
|
@ -294,8 +294,42 @@ Phaser.Cache.prototype = {
|
||||||
* @param {object} data - Extra image data.
|
* @param {object} data - Extra image data.
|
||||||
* @return {object} The full image object that was added to the cache.
|
* @return {object} The full image object that was added to the cache.
|
||||||
*/
|
*/
|
||||||
addImage: function (key, url, data) {
|
addImage: function (key, url, data)
|
||||||
|
{
|
||||||
|
if (this.checkImageKey(key))
|
||||||
|
{
|
||||||
|
this.removeImage(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Cache.addImage', key);
|
||||||
|
|
||||||
|
var img = {
|
||||||
|
key: key,
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
texture: this.game.textures.addImage(key, data)
|
||||||
|
};
|
||||||
|
|
||||||
|
this._cache.image[key] = img;
|
||||||
|
|
||||||
|
this._resolveURL(url, img);
|
||||||
|
|
||||||
|
// Remove this
|
||||||
|
if (key === '__default')
|
||||||
|
{
|
||||||
|
Phaser.Cache.DEFAULT = this.game.textures.getFrame('__default');
|
||||||
|
}
|
||||||
|
else if (key === '__missing')
|
||||||
|
{
|
||||||
|
Phaser.Cache.MISSING = this.game.textures.getFrame('__missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
return img;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
__addImage: function (key, url, data)
|
||||||
|
{
|
||||||
if (this.checkImageKey(key))
|
if (this.checkImageKey(key))
|
||||||
{
|
{
|
||||||
this.removeImage(key);
|
this.removeImage(key);
|
||||||
|
@ -347,10 +381,10 @@ Phaser.Cache.prototype = {
|
||||||
var obj = this.addImage('__default', null, img);
|
var obj = this.addImage('__default', null, img);
|
||||||
|
|
||||||
// Because we don't want to invalidate the sprite batch for an invisible texture
|
// Because we don't want to invalidate the sprite batch for an invisible texture
|
||||||
obj.base.skipRender = true;
|
// obj.base.skipRender = true;
|
||||||
|
|
||||||
// Make it easily available within the rest of Phaser / Pixi
|
// Make it easily available within the rest of Phaser / Pixi
|
||||||
Phaser.Cache.DEFAULT = new PIXI.Texture(obj.base);
|
// Phaser.Cache.DEFAULT = new PIXI.Texture(obj.base);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -372,7 +406,7 @@ Phaser.Cache.prototype = {
|
||||||
var obj = this.addImage('__missing', null, img);
|
var obj = this.addImage('__missing', null, img);
|
||||||
|
|
||||||
// Make it easily available within the rest of Phaser / Pixi
|
// Make it easily available within the rest of Phaser / Pixi
|
||||||
Phaser.Cache.MISSING = new PIXI.Texture(obj.base);
|
// Phaser.Cache.MISSING = new PIXI.Texture(obj.base);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ Phaser.TextureManager.prototype = {
|
||||||
|
|
||||||
addImage: function (key, source)
|
addImage: function (key, source)
|
||||||
{
|
{
|
||||||
|
console.log('TextureManager.addImage', key);
|
||||||
|
|
||||||
var texture = this.create(key, source);
|
var texture = this.create(key, source);
|
||||||
|
|
||||||
this.parsers.Image(texture, 0);
|
this.parsers.Image(texture, 0);
|
||||||
|
|
Loading…
Reference in a new issue