0 Favourites

[solved] How do I AJAX request a variable filename?

  • My game has a number of levels. For each level, I need to spawn sprites in various locations. I have created json files for each my levels containing info about which sprites to spawn and their locations. When a level begins, I use its json file to populate an array "LevelData" that the game then reads from to see what to create.

    My current logic looks like this:

    Global number CurLevel = 1

    System | On Start of Layout -> AJAX | Request level1.json(tag "currentleveldata")

    AJAX | On "currentleveldata" completed -> LevelData | Load from JSON string AJAX.LastData

    This all works fine but I need a way to request not a specific file like level1.json, but instead base the file name off of the level my player is currently on, like level[CurLevel].json. The dialog box for AJAX request is only giving me a drop-down menu to select files. I'm planning to include at least 50 different level setups so I really need a way to call a filename with a variable in it.

  • try with Ajax request URL : "level"&CurLevel&".json"

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • try with Ajax request URL : "level"&CurLevel&".json"

    You are a life-safer! thanks for the quick answer!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
150 20,720
Crow in the Snow's avatar
Crow in the Snow
Unread hot topic
99 10,136
karshinkoff's avatar
karshinkoff
Unread hot topic
0 Favourites
C3 Architect Request list
125 12,730
jayderyu's avatar
jayderyu