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.

Having said that, you will learn what I consider a cleaner workflow for your project, based on the design of the plugin.

  1. 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.

  2. 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.

  3. Do not evaluate API state conditions every tick; instead, react to the condition triggers.

  4. 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:

Recommended Workflow for your Games

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.

Cover

Step 1. Loading resources and NGIO initialization

Cover

Step 2. Asking the player to login

Cover

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

Cover

Step 4. Player's login in

Cover

Step 5. Player logged in and game ready to start.

Login Steps

  1. Make sure NGIO api is ready before being able to request a login.

  1. 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.

Login in on any key pressed, if the user is not logged in and the NGIO API is not waiting for a server response.
  1. 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.

On Waiting condition is triggered once.
Newgrounds Passport webpage
  1. 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.

On Logged In, a "Press any key" message is shown to start the game.
  1. Once your players logged in, you can prompt them to press any key to proceed to the next layout.

Changing the Layout only if the player is logged in.
Login built-in notification.

Demo Project Download

Last updated

Was this helpful?