Json Asset Pack

Hi,

I’ve just created my first json asset pack, images are loading as I wish :slight_smile:

Just curious, I wish to add some additional text content to the game objects within the json file, say like a characters name, which I want to pull through and display in game.

Can i do this within the original call to the json pack:

this.load.pack(‘main’, ‘assets/pack.json’);

Or does it require a second call (using load.json), like:

this.load.json(‘main’, ‘assets/pack.json’);

Thanks

1 Like

I believe you’d need to parse your JSON file with the additional metadata on your own, perhaps iterating through it to find the matching asset key and assigning the character name. You could also possibly extend the loader class, if you’re comfortable doing that.

1 Like

Hi, thanks for coming back to me. Could you please explain about extending the loading class?

Do you have any examples I can read up on?

Hello @old_blueyes

@prob is right you can use:

console.log(this.cache.json.get('jsonData'));

And you can find these type of examples on phaser3-examples-cache

Have Fun!! :smile:

1 Like

Hi @prob and @hcakar thank you both for your help all sorted :blush: