0 Favourites

Multiple APIs implemented in one project?

  • Hello everyone,

    I was wondering if there are some good practices on how to implement different website APIs in the same project. Let's say I want to have leaderboards and achievements on Gamejolt, clay.io and Newgrounds, how should I go about this? Use the same conditions and trigger everything at the same time, regardless of the website it's hosted or is there any way to detect the website in which the game is hosted?

    I am no expert in this matter and I'd like your opinion.

    Thanks :)

  • A quick and dirty approach could be as simple as defining a global var with the name of the target site.

    Meaning you would still have to export 3 times, but only change one variable for each export.

    On the events where you use the needed sdk, simply add a subevent checking for the global variable.

    Add a check for this variable where applicable to determine which to use.

    There is also a method to check the URL of a website through the browser object, through this you could determine what the global variable should be and have the process automated.

  • Maybe using different event sheets for each API and then triggering different functions depending on the URL would be an option? I just don't know how to detect the host...

    I mean, I would like to export my project only once and upload it to multiple sites at the same time, since I fix bugs and add features quite often.

  • The export takes only a minute so exporting different builds for each should not be that hard, especially if all you need to change for each one is a variable as mentioned above. I export for Windows 8, Google, Nook, Kindle, Tizen and more and have no problem exporting a separate copy for each one. It's really not hard and takes no extra effort than clicking your mouse. You still only have to fix the bug once, then just export again for each one.

  • There is a System condition for "Is on platform":

    Is on platform

    Test if currently running on a given platform, such as Android or as a Windows 8 app. Note it's possible multiple options can be true simultaneously. For example, if running in a browser on Android, both Is on platform Android and Is on platform HTML5 website will be true.

    Source: https://www.scirra.com/manual/124/system-conditions

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You can use the browser's object domain or url expression to access the current domain or URL.

    Then decide which API you want to talk to.

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