AidanPTD Posted March 22, 2018 Share Posted March 22, 2018 Hi, I'm (sort of) new to Phaser, and I was wondering about something: Is there an easier way to load tiles and items onto a level than something like this (see below)? { "platforms": [ {"image": "ground", "x": 0, "y": 920}, {"image": "ground", "x": 800, "y": 920}, {"image": "ground", "x": 1600, "y": 920}, {"image": "ground", "x": 2400, "y": 920}, {"image": "ground", "x": 3200, "y": 920}, {"image": "ground", "x": 3300, "y": 920}, {"image": "grass:4x1", "x": 420, "y": 794} ], "decoration": [ {"frame": 2, "x": 630, "y": 878}, {"frame": 2, "x": 663, "y": 878}, {"frame": 2, "x": 697, "y": 878}, {"frame": 3, "x": 756, "y": 878}, {"frame": 1, "x": 84, "y": 878}, {"frame": 0, "x": 252, "y": 878}, {"frame": 4, "x": 462, "y": 752} ], "coins": [ {"x": 147, "y": 899}, {"x": 189, "y": 899}, {"x": 399, "y": 773}, {"x": 357, "y": 794}, {"x": 336, "y": 836}, {"x": 819, "y": 899}, {"x": 861, "y": 899}, {"x": 903, "y": 899} ], "hero": {"x": 21, "y": 899}, "spiders": [ ], "door": {"x": 4800, "y": 920}, "copperkey": {"x": 899, "y": 710}, "silverkey": {"x": 800, "y": 874}, "goldkey": {"x": 500, "y": 674} } I currently have two levels, and it took me forever to get the x & y values correct when playing the game. Is there an easier way to do this, without having the x & y values if possible? I've seen examples on the Phaser site where the .JSON files have levels loaded with arrays of numbers and such, but I'm not sure if that'd work for me. Thank you to everyone in advance! P.S. IF anyone would like to see my progress on this project, check out the source code on GitHub: https://github.com/AidanPTD/Games Link to comment Share on other sites More sharing options...
Asisvenia Posted March 22, 2018 Share Posted March 22, 2018 Hello, Currently I'm developing a platform game without any frameworks I'm just writing my game with pure JS and yes you can draw your tiles without any x-y values. It is also very easy but I don't know are there any much better ways in the Phaser. Watch this video: https://www.youtube.com/watch?v=WMTv6QsAp0I&t= I hope it helps. Link to comment Share on other sites More sharing options...
Adel Posted March 22, 2018 Share Posted March 22, 2018 Try to use inkscape to build the scene, then put inkscape coordinates in the json file. Link to comment Share on other sites More sharing options...
Recommended Posts