How does AJAX works in a mobile phone?

0 favourites
  • 6 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • Hi all.

    I'm wondering why should I use Ajax to get the data if it was originally saved in the game. Can I get data without asking?

    How does it even work?

    Where can I read this?

    For example, I have a mobile game.

    The user has downloaded it. This Vile is on his mobile phone. I can't understand why should I use Ajax if the file is already downloaded?

    Thanks for any response.

  • Hello there,

    Ajax can be used to retrieve local JSON files, or to store data on your server via POST. Your game runs via web browser, which doesn't have access to the current project files. So, in order to retrieve the data in your project, you must access the data via AJAX call.

    I guess you have a text file or a json file which needs to be loaded into an array. In this case, you can request the project file, name the request with a specific tag name. Then, on competition using the same tag name, set the array using Ajax.LastData asJson.

    Read more here: https://www.construct.net/en/make-games/manuals/construct-3/plugin-reference/ajax

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi Ribis, thanks for you answer.

    "Your game runs via web browser"

    I understand correctly that mobile games (or operating systems - Windows, Mac) are also launched through the browser?

    Could you please tell me where can I find documentation on how the contract works on different operating systems?

    Of course I read the official documentation.

    is there more detailed documentation?

  • Hi Ribis, thanks for you answer.

    "Your game runs via web browser"

    I understand correctly that mobile games (or operating systems - Windows, Mac) are also launched through the browser?

    Could you please tell me where can I find documentation on how the contract works on different operating systems?

    Of course I read the official documentation.

    is there more detailed documentation?

    Construct 3 is used to make games/app which only runs on the web browser. Construct1 could export as an application, but it's not the case anymore.

    This is because, the app is made with Javascript, which runs only in a web browser. So, really the game run on a web page that has a canvas on it. This is good in some aspects because an app or game made with construct3 can run on any device which supports a web browser/javascript, however, the performance is not great as native export.

    That's why you need to use AJAX when you are trying to retrieve some specific data in the file. The web browser doesn't have direct access to the files if I'm right.

    check the export options: https://www.construct.net/en/make-games/manuals/construct-3/overview/publishing-projects

  • Construct is designed to run in web browsers as well as in apps. In web browsers, local resources must be loaded with a network fetch (via AJAX). In apps, the game runs in a browser engine, and local resources are still loaded the same way so everything works consistently across platforms. But in an app it will load a local file instead of using the network. In short it's for compatibility: you don't have to do anything different whether your game runs in a web browser or app.

    This is good in some aspects because an app or game made with construct3 can run on any device which supports a web browser/javascript, however, the performance is not great as native export.

    Try running some benchmarks and you may be surprised - JavaScript can be much faster than some other native technologies. For example JavaScript is much faster than GML, even though GML is compiled to C++.

  • Thank you for such an answer.

    I have another question that does not give me peace.

    I understood the fact that we use Ajax to receive data.

    if we compare getting data in a JSON file using yaks and for example if we create a JS code (main.js to data.js) that will return data.

    Will it affect performance?

    I have such a situation.

    I want to store data about objects in a json file, so pull this data up.

    I want to understand which method is the best.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)