Common Features
Language
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
ss.language;
// Current language, format ISO 639-1
SS_Language.Current();
To set language FREE:
- JavaScript
- Construct 3
- Unity
// set language, format ISO 639-1 ('ru', 'en', 'fr')
ss.changeLanguage('en');
// Format ISO 639-1 ('ru', 'en', 'fr')
SS_Language.Change(Language.en);
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}
*/
ss.isMobile;
/**
* Mobile / desktop device
* @readonly
* @type {boolean}
*/
SS_Device.IsMobile();
Screen mode: portrait / landscape
FREE- JavaScript
- Construct 3
- Unity
/**
* Portrait / landscape screen mode
* @readonly
* @type {boolean}
*/
ss.isPortrait;
/**
* Portrait / landscape screen mode
* @readonly
* @type {boolean}
*/
SS_Device.IsPortrait();
Subscribe to change orientation event:
- JavaScript
- Construct 3
- Unity
ss.on('change:orientation', (isPortrait) => {
logger.log('orientation changed', { isPortrait });
});
// Subscribe to an event
private void OnEnable()
{
SS_Device.OnChangeOrientation += OnChangeOrientation;
}
private void OnChangeOrientation()
{
Debug.Log("orientation changed");
}
Game Host Information
FREE- JavaScript
- Construct 3
- Unity
/**
* SpellSync in development mode
* The checkbox dev at the desired source is responsible for this
* @readonly
* @type {boolean}
*/
ss.isDev;
/**
* Game host in trusted sources
* The Allowed Origins section is responsible for this.
* @readonly
* @type {boolean}
*/
ss.isAllowedOrigin;
Is Dev Mode - SpellSync is in development mode. The dev checkbox is responsible for this at the desired site in Allowed Origins.
Is Allowed Origin - Host the game in trusted origins. The Allowed Origins section is responsible for this.
/**
* SpellSync in developer mode
* This is the responsibility of the "dev" checkbox at the desired source
* @readonly
* @type {boolean}
*/
SS_System.IsDev();
/**
* The game host is in trusted sources
* "Allowed Origins" is responsible for this
* @readonly
* @type {boolean}
*/
SS_System.IsAllowedOrigin();
You can use the ss.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 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
ss.serverTime;
// Example of using
// One hour in milliseconds
const HOUR = 60 * 60 * 1000;
// Current time
const currentDate = new Date(ss.serverTime);
// Previous reward time
const lastDate = new Date(ss.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) {
ss.player.add('gold', 5000);
ss.player.set('lastRewardTime', currentDate.toISOString());
}
// Current server time in format ISO 8601
SS_Server.Time();
// Usage example
DateTime dt = SS_Server.Time();
if (dt > lastDate)
{
SS_Player.AddScore(250);
}
Pause
You have access to the pause control mechanism in the game. The 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 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}
*/
ss.isPaused;
/**
* On pause
* @readonly
* @type {boolean}
*/
SS_Game.IsPaused();
Set pause manually FREE:
- JavaScript
- Construct 3
- Unity
// Pause game
ss.pause();
// Resume game
ss.resume();
SS_Game.Pause();
SS_Game.Resume();
Pause and resume events:
- JavaScript
- Construct 3
- Unity
// Paused
ss.on('pause', () => {});
// Resumed
ss.on('resume', () => {});
// Subscribe to an event
private void OnEnable()
{
SS_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
ss.setBackground({ url: '/bg.png' });
Not implemented in Unity.
Full features of the method:
- JavaScript
- Construct 3
- Unity
ss.setBackground({
// Image link
url: '/bg.png',
// Background image blur, px
blur: 10,
// Duration of image change animation, sec
fade: 5,
});
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
ss.setBackground({ url: '/bg.png', blur: 10, fade: 5 });
// Change to another
ss.setBackground({ url: '/bg2.png', blur: 6, fade: 12 });
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
ss.gameStart();
In Construct 3 is called automatically when the first layout is loaded.
You can manually send game start event.
Uncheck auto game-start event.
Then call SpellSync > Game Start action.
SS_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
ss.gameplayStart();
// Notify when finished
ss.gameplayStop();
// Notify when gameplay starts
SS_Game.GameplayStart();
// Notify when finished
SS_Game.GameplayStop();
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
SpellSync Community Telegram
: @spellsync.
For your suggestions e-mail
: [email protected]
We Wish you Success!
```