Hello. I’m new to Phaser and game dev in general.
I’ve hit a bit of a snag on my first project; I set up my project such that all the asset paths are contained within a json file along with other game object data. I realized too little too late that while you can load the json data within the preload function, game.cache.json.get apparently doesn’t return anything if called from preload; you instead have to call it from the create function.
The game I’m making is primarily a first-person point-and-click adventure game, and has a LOT of different screens, and I’d like to avoid listing them all in the actual body of the code, if possible. Keeping the asset paths in a data file seems like the more elegant solution, but the structure of Phaser is getting in the way of that. Is this Phaser’s way of pushing me towards a different structure that’s better suited for this, or is there simply a method I’m missing?
My main questions are:
(1) Is there a simple way to access json data in preload?
(2) Is it advisable?
(3) If not, what’s a better alternative?