Jump to content

Easier way to load tiles (or images) in levels?


AidanPTD
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...