Login Tutorial
Logging into newgrounds
The NewgroundsIO Plugin for Construct 3 was designed to work asynchronously to communicate with the NG backend. Therefore, you should follow some best practices to achieve the expected results.
Unlike other plugins, the NGIO Plugin is designed to act only when required. For instance, it’s unnecessary to check every tick to evaluate whether a user is logged in or not. Instead, use trigger events like On Login
or On Logout
conditions, and act accordingly. You can also use the Wait for previous action in the system plugin to delay execution until each asynchronous action call is completed.
Unlocking medals, posting to score boards and saving games require a player logged in. Failing to login will trigger the error conditions of NGIO plugin.
Having said that, you will learn what I consider a cleaner workflow for your project, based on the design of the plugin.
NGIO creates a Load Promise during initialization. This means your Construct game won’t start unless the NGIO libraries have loaded successfully, and your game API and AES keys are validated. Don’t forget to add this information in the plugin properties.
It’s strongly recommended to use a Game Loader layout. By this, I don’t refer to the Construct 3 loader layout, but to a game layout intended to load local resources and complete initializations before even showing the title screen. However, the game loader and the title screen responsibilities could be combined in a single layout. It's up to you to decide.
Do not evaluate API state conditions every tick; instead, react to the condition triggers.
Execute API calls only after the On Ready condition has been triggered, following the initialization of the NGIO API.
A typical layout flow for a game should look similar to this:

Once you are in the title screen, you will require your players to login to be able to use all the NGIO features like medals and scoreboards. Although, it may not be necessary to access most of the parts of your game. So, it's completely up to you to ask or not your players to login.
Layout Flow Recommended

Step 1. Loading resources and NGIO initialization

Step 2. Asking the player to login

Step 3. Notifing the game is waiting for a server response.

Step 4. Player's login in

Step 5. Player logged in and game ready to start.
Login Steps
Make sure NGIO api is ready before being able to request a login.

If your user is not logged in, call the action login once. It could be triggerd by a button pressed, a key-stroke or a touch event.

Notify your players the game is waiting for them to login. At this point, Newgrounds passport web-page is open asking them to grant permissions to your game.


If the user logs in successfully, the
On Login
condition will trigger. A login notification will appear with the user's name welcoming them back.

Once your players logged in, you can prompt them to press any key to proceed to the next layout.


Demo Project Download
Download the demo project to try these steps. Don't forget to set the AppId and AES Key to test the features.
Last updated
Was this helpful?