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

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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 Construct 3

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

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

  • 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)