Construct 3 (beta)

Beta: not verified with a real Construct export yet. The addon's files (addon.json, aces.json and the language file) are validated against Scirra's official Addon SDK v2 schemas, and the addon is tested against the real JavaScript SDK with a stand-in for Construct's runtime, but no Construct 3 export made with it has been checked end to end. If something does not work, tell us in the Support chat in your dashboard or at hello@gamealia.app: include your Construct release (Menu > About), whether "Use worker" is on, and what you expected to happen.

The Gamealia addon is a Construct 3 plugin (Addon SDK v2) that adds a single global object, Gamealia, to your project. It loads the JavaScript SDK, runs init() before your first layout, calls loadingStop() when the first layout starts, pauses and mutes the game while the portal asks it to, and gives you actions, conditions and expressions for ads, player accounts, cloud save, rooms, friends and leaderboards. It works with the project's Use worker setting on or off.

Install

  1. Download the addon: gamealia.c3addon.
  2. In Construct 3: Menu > View > Addon manager > Install new addon..., pick gamealia.c3addon, confirm, and restart Construct when it asks.
  3. In your project, right-click a layout > Insert new object > Gamealia (in "Platform specific"). It is a single global object: add it once, and every event sheet can use it.

The addon adds https://gamealia.app/sdk/v1.js to the exported index.html for you (and loads it at runtime if the tag is missing). Off the portal, in Construct's preview, the SDK runs in mock mode: fake ads, a local save, nothing is sent.

Minimal flow

WhenEvent
The game is loadednothing to do: init and Loading stop are automatic
TextsGamealia.Locale ("en", "es", "pt-BR"...), and Gamealia > On locale changed to translate again
Play starts (a level, a round)Gamealia > Gameplay start
Play stops (game over, pause menu, level end)Gamealia > Gameplay stop
A natural breakGamealia > Request midgame ad
Reward buttonGamealia > Request rewarded ad; give the reward in On rewarded ad completed

Ad actions are asynchronous: put System > Wait for previous actions to complete after them, or continue the game in On ad finished. While an ad plays the portal pauses and mutes the game.

Properties

PropertyDefaultWhat it does
Manual loading stopoffOff: Loading stop is called when the first layout starts. On: call it yourself once the game is playable (after your own loading screen).
Mute audio automaticallyonSilences the page's audio while the portal mutes the game (ads, the player's mute button). If a sound still plays, turn it off and use On mute / On unmute with Audio > Set silent.
Pause automaticallyonSets the time scale to 0 while the portal pauses the game and restores it on resume. Off: handle On pause / On resume yourself.

Actions, conditions and expressions

AreaActionsConditions and triggersExpressions
GeneralLoading start, Loading stop, Gameplay start, Gameplay stop, Happy time, Set progress, Set context, Clear context, Report error, Track eventOn init, On locale changed, Is on Gamealia, Is mobile, Is instant multiplayer, Is chat offLocale, Environment, GameId, Device, DeviceClass, Country, App, OsName, OsVersion, BrowserName, BrowserVersion, LastError
AdsRequest midgame ad, Request rewarded ad, Check adblock, Request banner, Request responsive banner, Clear banner, Clear all bannersOn ad started, On ad ended, On ad finished, On rewarded ad completed, On rewarded ad skipped, Is ad playing, Has adblock, On banner shown, On banner failedLastAdShown, LastAdRewarded, LastAdReason, BannerId, BannerReason, BannerSize
Pause and audioOn pause, On resume, On mute, On unmute, Is paused, Is muted
Player accountRequest login, Refresh user, Request tokenOn user changed, On login finished, On token received, Is signed inUsername, UserId, AvatarUrl, Token
Cloud saveLoad data, Set data, Set data (JSON), Remove data, Clear dataOn data loaded, Has dataData(key)
Rooms and invitesPublish room, Unpublish room, Show invite, Request invite link, Request join pass, Join failed, Set presence statusOn room join, On invite link ready, On join pass ready, Has join codeJoinCode, JoinKey, JoinParam(name), InviteLink, JoinPass
FriendsRequest friends list, Invite friendOn friends list ready, On friend invite sent, On friends changed, Was invite deliveredFriendCount, FriendId(i), FriendName(i), FriendAvatarUrl(i), FriendOnline(i), FriendPlaying(i), FriendRoomCode(i)
LeaderboardsSubmit score, Get leaderboard, Show leaderboardOn score submitted, On leaderboard ready, Was score acceptedLastBest, LastRank, LeaderboardCount, LeaderboardTotal, LeaderboardName(i), LeaderboardValue(i), LeaderboardRank(i), LeaderboardIsMe(i), MyRank

Each one maps to the JavaScript SDK call of the same name (SDK reference). A few details:

  • Cloud save: run Load data once (for example in On init), then read Gamealia.Data("key"). Numbers and texts come back as they are; arrays and objects come back as JSON (use Set data (JSON) with Array.AsJSON or Dictionary.AsJSON, and Load on the Array or Dictionary to read them).
  • Player accounts: guests must be able to play. Request token gives a token for your own server; see Player accounts.
  • Rooms: when Has join code is true at start (or in On room join), join the room Gamealia.JoinCode in your own netcode; see Multiplayer.
  • Leaderboards: boards are set up in the dashboard; see Leaderboards.
  • Lists (friends, leaderboard entries) are 0-based: loop with System > Repeat FriendCount times and use loopindex.

JavaScript-only features

Chat, store and the other extras of the SDK reference have no actions. Call them from a script in your event sheet with Use worker set to No (Project properties > Advanced), because only then do your scripts run in the page next to globalThis.Gamealia:

const r = await globalThis.Gamealia.chat.join("global");

Export

  1. Menu > Project > Export > Web (HTML5).
  2. Unzip the export and upload that folder, with index.html at its root (or zip it as it is).
  3. Keep the export's own files: scripts/, data.json, workermain.js, the service worker and offline.json. Gamealia serves every version at its own URL, so offline caching cannot show an old version.

Already use another portal's Construct plugin?

If that plugin loads the other portal's SDK from a script tag in the exported index.html, our compatibility shim can take its place, as the migration guides explain. Most Construct plugins load their SDK themselves, though: then replace it with the Gamealia addon and move its events to the Gamealia ones (same idea: loading, gameplay start and stop, midgame and rewarded ads).

Common autotest failures

  • gameplay_start / gameplay_stop: no Gameplay start / Gameplay stop actions in your events.
  • loading_stop: Manual loading stop is on and the action is never reached.
  • sdk_loaded: the export was made before the addon was added, or index.html was replaced by a custom one without the SDK tag. Export again.
  • translations: texts set once from Gamealia.Locale without On locale changed.

Problems or questions: the Support chat in your dashboard, or hello@gamealia.app (Support).