Common Features
Languageโ
GamePush SDK can autodetect players language. If the platform provides a language, we use it or pick player-preferred language.
To check language FREE:
- JavaScript
- Construct 3
- Unity
// Current language, format ISO 639-1
gp.language;
Legend
System
Text
GamePush
SystemโบConstruct 3 System object
Text โ Object Text (Text)
GamePushโบGamePush plugin
// Current language, format enum Language ("English", "Russian")
GP_Language.Current();
// Current language, format ISO 639-1
GP_Language.CurrentISO();
To set language FREE:
- JavaScript
- Construct 3
- Unity
// set language, format ISO 639-1 ('ru', 'en', 'fr')
gp.changeLanguage("ru");
Legend
System
GamePush
SystemโบConstruct 3 System object
GamePushโบGamePush plugin
// Format enum Language ("English", "Russian")
GP_Language.Change(Language.English);
// Format ISO 639-1 ('ru', 'en', 'fr')
GP_Language.Change("ru");
All supported languages:
- English:
en - French:
fr - Italian:
it - German:
de - Spanish:
es - Chinese (Simplified):
zh - Portuguese (Brazil):
pt - Korean:
ko - Japanese:
ja - Russian:
ru - Turkish:
tr - Arab:
ar - Hindi:
hi - Indonesian:
id
System Informationโ
Device detectionโ
FREE- JavaScript
- Construct 3
- Unity
/**
* Mobile / desktop device
* @readonly
* @type {boolean}
*/
gp.isMobile;
Legend
GamePush
GamePushโบGamePush plugin
/**
* Mobile / desktop device
* @readonly
* @type {boolean}
*/
GP_Device.IsMobile();
Screen mode: portrait / landscapeโ
FREE- JavaScript
- Construct 3
- Unity
/**
* Portrait / landscape screen mode
* @readonly
* @type {boolean}
*/
gp.isPortrait;
Legend
GamePush
GamePushโบGamePush plugin
/**
* Portrait / landscape screen mode
* @readonly
* @type {boolean}
*/
GP_Device.IsPortrait();
Subscribe to change orientation event:
- JavaScript
- Construct 3
- Unity
gp.on("change:orientation", (isPortrait) => {
logger.log("orientation changed", { isPortrait });
});
Legend
GamePush
System
GamePushโบGamePush plugin
SystemโบConstruct 3 System object
// Subscribe to an event
private void OnEnable()
{
GP_Device.OnChangeOrientation += OnChangeOrientation;
}
private void OnChangeOrientation()
{
Debug.Log("orientation changed");
}
Game Host Informationโ
FREE- JavaScript
- Construct 3
- Unity
/**
* GamePush in development mode
* The checkbox dev at the desired source is responsible for this
* @readonly
* @type {boolean}
*/
gp.isDev;
/**
* Game host in trusted sources
* The Allowed Origins section is responsible for this.
* @readonly
* @type {boolean}
*/
gp.isAllowedOrigin;
Legend
GamePush
GamePushโบGamePush plugin
Is Dev mode โ GamePush is in development mode. Controlled by the dev flag for the site in Allowed Origins.
Is Allowed Origin โ The game host is in trusted origins. Controlled in Allowed Origins.
/**
* GamePush in developer mode
* This is the responsibility of the "dev" checkbox at the desired source
* @readonly
* @type {boolean}
*/
GP_System.IsDev();
/**
* The game host is in trusted sources
* "Allowed Origins" is responsible for this
* @readonly
* @type {boolean}
*/
GP_System.IsAllowedOrigin();
You can use the gp.isAllowedOrigin property to check whether the game has been re-uploaded to another site. In the Allowed Origins section there is a switch - Enable origin protection. It will block all new unknown game hosts. In the list of hosts, you can allow access to the desired hosts.
Server Timeโ
FREEThe GamePush SDK provides access to server time.
It is always valid, it cannot be changed through the code and by changing the time of the device. You can use it as a reliable time to protect against cheating.
To get time FREE:
- JavaScript
- Construct 3
- Unity
// Read-only current server time in ISO 8601 format
gp.serverTime;
// Example of using
// One hour in milliseconds
const HOUR = 60 * 60 * 1000;
// Current time
const currentDate = new Date(gp.serverTime);
// Previous reward time
const lastDate = new Date(
gp.player.get("lastRewardTime") || currentDate - HOUR
);
// If an hour of playing time has passed, we give a reward
// And update the time of last reward
if (currentDate - lastDate > HOUR) {
gp.player.add("gold", 5000);
gp.player.set("lastRewardTime", currentDate.toISOString());
}
Legend
System
Text
SystemโบConstruct 3 System object
Text โ Object Text (Text)
Expressions: GamePush.ServerTime (ISO 8601), GamePush.ServerTimeUnix (ms).
// Current server time in format ISO 8601
GP_Server.Time();
// Usage example
DateTime dt = GP_Server.Time();
if (dt > lastDate)
{
GP_Player.AddScore(250);
}
Pauseโ
You have access to the pause control mechanism in the game. The GamePush SDK has a "Paused" flag, by itself it means nothing, however, you can engage in it if you need to pause and continue the game. Additionally, the GamePush SDK will notify you when a pause or resume has been triggered.
Auto pause occurs when:
- Show ads. Pause at the beginning of the show and resume at the close (not when receiving an award).
- Minimize game. Pause when switching tabs, minimizing the browser, switching applications, locking the screen, and resuming when the game is visible again.
Pause definition FREE:
- JavaScript
- Construct 3
- Unity
/**
* Is on pause
* @readonly
* @type {boolean}
*/
gp.isPaused;
Legend
GamePush
GamePushโบGamePush plugin
/**
* On pause
* @readonly
* @type {boolean}
*/
GP_Game.IsPaused();
Set pause manually FREE:
- JavaScript
- Construct 3
- Unity
// Pause game
gp.pause();
// Resume game
gp.resume();
Legend
Button
GamePush
Button โ Object Button (Button)
GamePushโบGamePush plugin
GP_Game.Pause();
GP_Game.Resume();
Pause and resume events:
- JavaScript
- Construct 3
- Unity
// Paused
gp.on("pause", () => {});
// Resumed
gp.on("resume", () => {});
Legend
GamePush
Functions
GamePushโบGamePush plugin
Functions โ Object Functions (Functions)
// Subscribe to an event
private void OnEnable()
{
GP_Game.OnPause += Pause;
}
private void Pause()
{
Debug.Log("is Pause");
}
Set background imageโ
FREEYou can set the background of the game.
Background set method:
- JavaScript
- Construct 3
- Unity
gp.setBackground({ url: "/bg.png" });
Legend
System
GamePush
SystemโบConstruct 3 System object
GamePushโบGamePush plugin
Not implemented in Unity.
Full features of the method:
- JavaScript
- Construct 3
- Unity
gp.setBackground({
// Image link
url: "/bg.png",
// Background image blur, px
blur: 10,
// Duration of image change animation, sec
fade: 5,
});
Legend
System
GamePush
SystemโบConstruct 3 System object
GamePushโบGamePush plugin
Not implemented in Unity.
You can call the method one by one to change the background image, for example:
- JavaScript
- Construct 3
- Unity
// Set background
gp.setBackground({ url: "/bg.png", blur: 10, fade: 5 });
// Change to another
gp.setBackground({ url: "/bg2.png", blur: 6, fade: 12 });
Legend
System
GamePush
SystemโบConstruct 3 System object
GamePushโบGamePush plugin
Not implemented in Unity.
Start gameโ
FREEGame start method, required by some sites to set at the start of the game
- JavaScript
- Construct 3
- Unity
The call should depend after the game is loaded:
gp.gameStart();
By default the call happens automatically (plugin property Auto-send game start event). You can also call it manually after the game loads:
Legend
System
GamePush
SystemโบConstruct 3 System object
GamePushโบGamePush plugin
GP_Game.GameReady();
You can also call it automatically.
Gameplayโ
FREEFor some platforms, such as POKI and CrazyGames, you need to call the start and end gameplay methods. They need to be called immediately before the start of the gameplay and immediately after completion. For example, at the beginning of the level and the end of the level.
- JavaScript
- Construct 3
- Unity
// Notify when gameplay starts
gp.gameplayStart();
// Notify when finished
gp.gameplayStop();
Legend
Button
GamePush
Button โ Object Button (Button)
GamePushโบGamePush plugin
// Notify when gameplay starts
GP_Game.GameplayStart();
// Notify when finished
GP_Game.GameplayStop();
Stay in Touchโ
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
GamePush Community Telegram: @gs_community.
For your suggestions e-mail: official@gamepush.com
We Wish you Success!