Fix function ParseJSONTiled
This PR
- Fixes a bug
A call to the ParseJSONTiled function changes the object passed as the second argument of the function, so that when this function is called again with the same object, the function returns a different result than the first call to this function.
This PR also fixes a problem described in https://github.com/photonstorm/phaser/issues/6212
before:

after (Desired result):

Thanks for the PR. I'd be more inclined to see what is it about ParseObjectLayers that mutates the data (because most of the things this parser does is perfectly safe, just copying numbers across)
ParseObjectLayers
The ParseObjectLayers function edits the json object passed to it, so when the function gameScene.make. tilemap({key: "map1"});the function passes this changed json object as an argument to the ParseJSONTiled function, which then edits the same object again, since the changed object has a name with a prefix and the ParseObjectLayers function reapplies the prefix.
Solution options:
- It is necessary to pass a copy of the json object to the
ParseObjectLayersfunction so that its changes to that object do not edit the main object. - It's necessary to forbid the
ParseObjectLayersfunction to edit the object, but use ordinary variables instead of storing the changed data. - It is necessary to make a copy of exactly those objects which are edited by the
ParseObjectLayersfunction.
Looking at it, nothing in ParseObjectLayers mutates the json, so it must be even deeper than that - likely in CreateGroupLayer.
Just checked and nope, nothing in there does it either! However, it does do this: layers: json.layers, which returns the whole original object, so I guess something outside of the parser then edits this, thinking the data is safe. It may be enough just to set that to be a cloned object.
You can clone only json.layers, but in my solution I clone the whole json, because besides mapData.objects = ParseObjectLayers(json); the ParseJSONTiled function calls other parsers like mapData.images = ParseImageLayers(copyJsonData); and I suspect they can edit the object too (I haven't checked if they edit the json object)
Thanks, I'm going to do this the same way you have, but just with a different property name. This is now in the master branch (and attributed to you in the Change Log).