Skip to content

Commit 6626870

Browse files
committed
Adding DEFAULT and MISSING images to Game Config and the Texture Manager.
1 parent 63c11fa commit 6626870

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

v3/src/boot/Config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ var Config = function (config)
6060
// Callbacks
6161
this.preBoot = GetObjectValue(config, 'callbacks.preBoot', NOOP);
6262
this.postBoot = GetObjectValue(config, 'callbacks.postBoot', NOOP);
63+
64+
// Default / Missing Images
65+
this.defaultImage = GetObjectValue(config, 'images.default', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==');
66+
this.missingImage = GetObjectValue(config, 'images.missing', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==');
6367
};
6468

6569
Config.prototype.constructor = Config;

v3/src/textures/TextureManager.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,30 @@ var TextureManager = function (game)
2323
this.game = game;
2424

2525
this.list = {};
26+
27+
this.addBase64('__DEFAULT', game.config.defaultImage);
28+
this.addBase64('__MISSING', game.config.missingImage);
2629
};
2730

2831
TextureManager.prototype.constructor = TextureManager;
2932

3033
TextureManager.prototype = {
3134

35+
addBase64: function (key, data)
36+
{
37+
var _this = this;
38+
var image = new Image();
39+
40+
image.onload = function ()
41+
{
42+
var texture = _this.create(key, image);
43+
44+
Parser.Image(texture, 0);
45+
};
46+
47+
image.src = data;
48+
},
49+
3250
addImage: function (key, source)
3351
{
3452
var texture = this.create(key, source);

0 commit comments

Comments
 (0)