Skip to content

Commit 509cceb

Browse files
author
Matt Colman
committed
support file-loader and json-loader
1 parent 3c9dc08 commit 509cceb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/AssetLoader.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { Plugin } from 'phaser'
2+
import isString from 'lodash/isString'
3+
import isObject from 'lodash/isObject'
24

35
function warn (type, key) {
46
console.warn(`phaser-manifest-loader: could not find ${type} with key : ${key}`)
@@ -64,18 +66,18 @@ export default class AssetLoader extends Plugin {
6466
}
6567

6668
loadSpriteSheet (key, assetPostfix) {
67-
let imageUrl, jsonUrl
69+
let imageUrl, json
6870
try {
6971
imageUrl = this.req(`./spritesheets/${key}${assetPostfix}.png`)
7072
} catch (e) {}
7173

7274
try {
73-
jsonUrl = this.req(`./spritesheets/${key}${assetPostfix}.json`)
75+
json = this.req(`./spritesheets/${key}${assetPostfix}.json`)
7476
} catch (e) {}
7577

7678
if (!imageUrl) warn('spriteSheet image', key)
77-
if (!jsonUrl) warn('spriteSheet json', key)
78-
this.game.load.atlasJSONArray(key, imageUrl, jsonUrl)
79+
if (!json) warn('spriteSheet json', key)
80+
this.game.load.atlasJSONArray(key, imageUrl, isString(json) && json, isObject(json) && json)
7981
}
8082

8183
loadImage (key, assetPostfix) {

0 commit comments

Comments
 (0)