Skip to content

Commit e0ef9ca

Browse files
committed
Hooked the Texture Manager into the Cache.
1 parent 7072923 commit e0ef9ca

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

src/loader/Cache.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,42 @@ Phaser.Cache.prototype = {
294294
* @param {object} data - Extra image data.
295295
* @return {object} The full image object that was added to the cache.
296296
*/
297-
addImage: function (key, url, data) {
297+
addImage: function (key, url, data)
298+
{
299+
if (this.checkImageKey(key))
300+
{
301+
this.removeImage(key);
302+
}
303+
304+
console.log('Cache.addImage', key);
305+
306+
var img = {
307+
key: key,
308+
url: url,
309+
data: data,
310+
texture: this.game.textures.addImage(key, data)
311+
};
312+
313+
this._cache.image[key] = img;
314+
315+
this._resolveURL(url, img);
316+
317+
// Remove this
318+
if (key === '__default')
319+
{
320+
Phaser.Cache.DEFAULT = this.game.textures.getFrame('__default');
321+
}
322+
else if (key === '__missing')
323+
{
324+
Phaser.Cache.MISSING = this.game.textures.getFrame('__missing');
325+
}
326+
327+
return img;
328+
329+
},
298330

331+
__addImage: function (key, url, data)
332+
{
299333
if (this.checkImageKey(key))
300334
{
301335
this.removeImage(key);
@@ -347,10 +381,10 @@ Phaser.Cache.prototype = {
347381
var obj = this.addImage('__default', null, img);
348382

349383
// Because we don't want to invalidate the sprite batch for an invisible texture
350-
obj.base.skipRender = true;
384+
// obj.base.skipRender = true;
351385

352386
// Make it easily available within the rest of Phaser / Pixi
353-
Phaser.Cache.DEFAULT = new PIXI.Texture(obj.base);
387+
// Phaser.Cache.DEFAULT = new PIXI.Texture(obj.base);
354388

355389
},
356390

@@ -372,7 +406,7 @@ Phaser.Cache.prototype = {
372406
var obj = this.addImage('__missing', null, img);
373407

374408
// Make it easily available within the rest of Phaser / Pixi
375-
Phaser.Cache.MISSING = new PIXI.Texture(obj.base);
409+
// Phaser.Cache.MISSING = new PIXI.Texture(obj.base);
376410

377411
},
378412

src/textures/TextureManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Phaser.TextureManager.prototype = {
4242

4343
addImage: function (key, source)
4444
{
45+
console.log('TextureManager.addImage', key);
46+
4547
var texture = this.create(key, source);
4648

4749
this.parsers.Image(texture, 0);

0 commit comments

Comments
 (0)