Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/states/LoaderState.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class extends Phaser.State {
const req = require.context(
'../../assets',
true,
/.*\.png|json|ttf|woff|woff2|xml|mp3|jpg|jpeg$/
/.*\.png|json|ttf|woff|woff2|xml|mp3|jpg|jpeg|json$/
)
this.manifestLoader = this.game.plugins.add(ManifestLoader, req)
// What I like about the ManifestLoader is that `loadManifest` returns
Expand Down
15 changes: 15 additions & 0 deletions lib/AssetLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var AssetLoader = function (_Phaser$Plugin) {
'audio': this.loadAudio,
'spritesheets': this.loadSpriteSheet,
'images': this.loadImage,
'json': this.loadJson,
'bitmap_fonts': this.loadBitmapFont
};
}
Expand Down Expand Up @@ -137,6 +138,20 @@ var AssetLoader = function (_Phaser$Plugin) {
this.game.load.image(key, urls[0]);
}
}
}, {
key: 'loadJson',
value: function loadJson(key, assetPostfix) {
var urls = [];
try {
urls.push(this.req('./json/' + key + assetPostfix + '.json'));
} catch (e) {}

if (urls.length === 0) {
warn('json', key);
} else {
this.game.load.json(key, urls[0]);
}
}
}, {
key: 'loadBitmapFont',
value: function loadBitmapFont(key, assetPostfix) {
Expand Down
Loading