I’m having a situation with a json file which contains the sequence of the enemies spawn. Everytime (from the second time) the scene starts, the data loaded from the json file will be scrambled. The integer values cumulate and contains weird numbers.
To clarify the situation. The first time, the data loads properly. The second time, the data will be scrambled.
Thank you very much for your reply. I have used to vanilla javascript function “fetch” as a workaround, and it works fine now. However, I still don’t know what happened with json.get() function though. I have wasted a lot of time to figure out the problem.
Here is the solution :
fetch(‘assets/level.json’)
.then(response => response.json())
.then(data => {
this.waveController.create(data);
})
There’s nothing wrong with json.get(), you just have to remember that you get the original object from the cache, not a copy. If you modify it, then get it from the cache again, it’s still modified.