Skip to Content
defold-typescript libraries
megalanthusdefold-gamepush

megalanthus/defold-gamepush/gamepush

GamePush (previously GameScore) is the GamePush SDK implementation for the Defold game engine.

  • GitHub: megalanthus/defold-gamepush — pinned to v1.4.1
    1. Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as gamepush from "gamepush.gamepush"

Functions

init(callback: (success: boolean) => void)

Initializes GamePush. Call it once, before any other function. Raises when called twice, without a callback, or when gamepush.id or gamepush.token is missing from game.project.

Parameters

  • callback: (success: boolean) => void — Receives whether initialization succeeded.

language(): string

The current language, as an ISO 639-1 code.

Returns

  • string

change_language(language_code: string)

Sets the language. Raises when the code is not a string.

Parameters

  • language_code: string — The ISO 639-1 code, for example languages.RUSSIAN.

is_mobile(): boolean

Whether the game runs on a mobile device.

Returns

  • boolean

is_portrait(): boolean

Whether the screen is in portrait orientation.

Returns

  • boolean

is_dev(): boolean

Whether the game runs in development mode.

Returns

  • boolean

is_allowed_origin(): boolean

Whether the game's host is a trusted origin.

Returns

  • boolean

get_server_time(): string

The server time, in ISO 8601 format.

Returns

  • string

is_paused(): boolean

Whether the game is paused.

Returns

  • boolean

pause()

Pauses the game.

resume()

Resumes the game.

set_background(parameters: Record<string, unknown>)

Sets the game's background image. Raises when the table is missing.

Parameters

  • parameters: Record<string, unknown> — The background, for example { url: "/image.png" }.

game_start()

Reports that the game has finished loading.

is_game_started(): boolean

Whether the game has finished loading.

Returns

  • boolean

gameplay_start()

Reports that gameplay started.

gameplay_stop()

Reports that gameplay stopped.

is_game_play(): boolean

Whether gameplay is running.

Returns

  • boolean

get_plugin_version(): string

The plugin's version string.

Returns

  • string

Variables

callbacks: CommonCallbacks

The common event handlers.

languages: { readonly ENGLISH: "en"; readonly RUSSIAN: "ru"; readonly FRENCH: "fr"; readonly ITALIAN: "it"; readonly GERMAN: "de"; readonly SPANISH: "es"; readonly CHINESE: "zh"; readonly PORTUGUESE: "pt"; readonly KOREAN: "ko"; readonly JAPANESE: "ja"; readonly TURKISH: "tr"; readonly ARAB: "ar"; readonly HINDI: "hi"; readonly INDONESIAN: "id"; }

The ISO 639-1 codes of the languages GamePush supports.

app: typeof import('gamepush.core.app')

The game's application details, reviews and shortcuts.

platform: typeof import('gamepush.core.platform')

The platform the game runs on and its native SDK.

player: typeof import('gamepush.core.player')

The current player.

players: typeof import('gamepush.core.players')

Other players' data.

payments: typeof import('gamepush.core.payments')

In-game purchases and subscriptions.

leaderboard: typeof import('gamepush.core.leaderboard')

Leaderboards.

channels: typeof import('gamepush.core.channels')

Channels and chats.

events: typeof import('gamepush.core.events')

Events.

rewards: typeof import('gamepush.core.rewards')

Rewards.

schedulers: typeof import('gamepush.core.schedulers')

Reward schedulers.

triggers: typeof import('gamepush.core.triggers')

Triggers.

ads: typeof import('gamepush.core.ads')

Advertising.

achievements: typeof import('gamepush.core.achievements')

Achievements.

socials: typeof import('gamepush.core.socials')

Social actions: sharing, posts, invites and communities.

variables: typeof import('gamepush.core.variables')

Game variables.

games_collections: typeof import('gamepush.core.games_collections')

Games collections.

images: typeof import('gamepush.core.images')

Images.

files: typeof import('gamepush.core.files')

Files.

documents: typeof import('gamepush.core.documents')

Documents such as the privacy policy.

analytics: typeof import('gamepush.core.analytics')

Analytics.

fullscreen: typeof import('gamepush.core.fullscreen')

Fullscreen.

sounds: typeof import('gamepush.core.sounds')

Sounds.

logger: typeof import('gamepush.core.logger')

Toasts and console logs.

storage: typeof import('gamepush.core.storage')

Key-value storage.

segments: typeof import('gamepush.core.segments')

Player segments.

experiments: typeof import('gamepush.core.experiments')

Experiments.

feedbacks: typeof import('gamepush.core.feedbacks')

Feedback.

reactions: typeof import('gamepush.core.reactions')

Reactions.

uniques: typeof import('gamepush.core.uniques')

Unique values.

multiplayer: typeof import('gamepush.core.multiplayer')

Multiplayer.

windows: typeof import('gamepush.core.windows')

Overlay windows.

social_actions: typeof import('gamepush.core.socials')

The same module as socials.

Types

CommonCallbacks

CommonCallbacks.change_orientation?: (is_portrait: boolean) => void

The screen orientation changed.

CommonCallbacks.pause?: () => void

The game was paused.

CommonCallbacks.resume?: () => void

The game was resumed.

CommonCallbacks.event_connect?: () => void

Another window of the game connected.

On this page

Functionsinit(callback: (success: boolean) => void)language(): stringchange_language(language_code: string)is_mobile(): booleanis_portrait(): booleanis_dev(): booleanis_allowed_origin(): booleanget_server_time(): stringis_paused(): booleanpause()resume()set_background(parameters: Record<string, unknown>)game_start()is_game_started(): booleangameplay_start()gameplay_stop()is_game_play(): booleanget_plugin_version(): stringVariablescallbacks: CommonCallbackslanguages: { readonly ENGLISH: "en"; readonly RUSSIAN: "ru"; readonly FRENCH: "fr"; readonly ITALIAN: "it"; readonly GERMAN: "de"; readonly SPANISH: "es"; readonly CHINESE: "zh"; readonly PORTUGUESE: "pt"; readonly KOREAN: "ko"; readonly JAPANESE: "ja"; readonly TURKISH: "tr"; readonly ARAB: "ar"; readonly HINDI: "hi"; readonly INDONESIAN: "id"; }app: typeof import('gamepush.core.app')platform: typeof import('gamepush.core.platform')player: typeof import('gamepush.core.player')players: typeof import('gamepush.core.players')payments: typeof import('gamepush.core.payments')leaderboard: typeof import('gamepush.core.leaderboard')channels: typeof import('gamepush.core.channels')events: typeof import('gamepush.core.events')rewards: typeof import('gamepush.core.rewards')schedulers: typeof import('gamepush.core.schedulers')triggers: typeof import('gamepush.core.triggers')ads: typeof import('gamepush.core.ads')achievements: typeof import('gamepush.core.achievements')socials: typeof import('gamepush.core.socials')variables: typeof import('gamepush.core.variables')games_collections: typeof import('gamepush.core.games_collections')images: typeof import('gamepush.core.images')files: typeof import('gamepush.core.files')documents: typeof import('gamepush.core.documents')analytics: typeof import('gamepush.core.analytics')fullscreen: typeof import('gamepush.core.fullscreen')sounds: typeof import('gamepush.core.sounds')logger: typeof import('gamepush.core.logger')storage: typeof import('gamepush.core.storage')segments: typeof import('gamepush.core.segments')experiments: typeof import('gamepush.core.experiments')feedbacks: typeof import('gamepush.core.feedbacks')reactions: typeof import('gamepush.core.reactions')uniques: typeof import('gamepush.core.uniques')multiplayer: typeof import('gamepush.core.multiplayer')windows: typeof import('gamepush.core.windows')social_actions: typeof import('gamepush.core.socials')TypesCommonCallbacksCommonCallbacks.change_orientation?: (is_portrait: boolean) => voidCommonCallbacks.pause?: () => voidCommonCallbacks.resume?: () => voidCommonCallbacks.event_connect?: () => void