System¶
Description¶
System is a virtual platform-abstraction layer. It provides screen dimensions, file-system paths, virtual keyboard control, fullscreen management, persistent key-value storage, and optional SDK integrations (AdMob, CrazyGames). You access it via System::instance() in C++ or the global System table in Lua.
Each target platform provides its own concrete System subclass; the engine injects the correct implementation at startup.
Methods¶
| Returns | Name | Languages |
|---|---|---|
| int | getScreenWidth | C++ | Lua |
| int | getScreenHeight | C++ | Lua |
| int | getSampleCount | C++ | Lua |
| void | showVirtualKeyboard | C++ | Lua |
| void | hideVirtualKeyboard | C++ | Lua |
| bool | isFullscreen | C++ | Lua |
| void | requestFullscreen | C++ | Lua |
| void | exitFullscreen | C++ | Lua |
| char | getDirSeparator | C++ | Lua |
| std::string | getAssetPath | C++ | Lua |
| std::string | getUserDataPath | C++ | Lua |
| std::string | getLuaPath | C++ | Lua |
| std::string | getShaderPath | C++ | Lua |
| bool | getBoolForKey | C++ | Lua |
| int | getIntegerForKey | C++ | Lua |
| long | getLongForKey | C++ | Lua |
| float | getFloatForKey | C++ | Lua |
| double | getDoubleForKey | C++ | Lua |
| std::string | getStringForKey | C++ | Lua |
| void | setBoolForKey | C++ | Lua |
| void | setIntegerForKey | C++ | Lua |
| void | setLongForKey | C++ | Lua |
| void | setFloatForKey | C++ | Lua |
| void | setDoubleForKey | C++ | Lua |
| void | setStringForKey | C++ | Lua |
| void | removeKey | C++ | Lua |
Method details¶
getScreenWidth / getScreenHeight¶
virtual int getScreenWidth() = 0virtual int getScreenHeight() = 0
Physical screen (window) dimensions in pixels. These may differ from Engine::canvasWidth / canvasHeight when a scaling mode other than NATIVE is active.
getSampleCount¶
virtual int getSampleCount()
Returns the MSAA sample count configured for the current graphics backend (e.g. 1, 2, or 4). Useful when creating render targets that must match the main framebuffer.
showVirtualKeyboard¶
virtual void showVirtualKeyboard(std::wstring text = L"")
Displays the platform's on-screen keyboard with text as the initial input buffer. Has no effect on desktop platforms. On iOS/Android, raises the software keyboard and fires Engine::onCharInput for each key typed.
hideVirtualKeyboard¶
virtual void hideVirtualKeyboard()
Dismisses the on-screen keyboard.
isFullscreen / requestFullscreen / exitFullscreen¶
virtual bool isFullscreen()virtual void requestFullscreen()virtual void exitFullscreen()
Query and control fullscreen mode. On desktop platforms, requestFullscreen() typically toggles borderless fullscreen; on web, it requests the Fullscreen API. Has no effect on mobile (always fullscreen).
getDirSeparator¶
virtual char getDirSeparator()
Returns the platform path directory separator: '/' on Unix/macOS/iOS/Android/Web, '\\' on Windows.
getAssetPath¶
virtual std::string getAssetPath()
Returns the root path for read-only assets bundled with the project. Prepend this to asset file names when opening files directly from C++. In Lua and the high-level C++ loaders (setTexture, etc.), paths are automatically resolved relative to the asset root.
getUserDataPath¶
virtual std::string getUserDataPath()
Returns a writable per-user data directory (Documents on iOS, internal storage on Android, %AppData% on Windows, ~/.local/share on Linux). Use for save files and configuration.
getLuaPath¶
virtual std::string getLuaPath()
Returns the base path prepended when Lua require() looks for script modules.
getShaderPath¶
virtual std::string getShaderPath()
Returns the path where compiled shader binaries are expected. Relevant for custom shader loading.
Persistent key–value storage¶
The system exposes a simple cross-platform persistent store backed by NSUserDefaults (iOS/macOS), SharedPreferences (Android), localStorage (Web), and a JSON file (desktop/Linux/Windows).
Getters return the stored value or defaultValue if the key does not exist:
| Method | Type |
|---|---|
getBoolForKey(key, defaultValue) |
bool |
getIntegerForKey(key, defaultValue) |
int |
getLongForKey(key, defaultValue) |
long |
getFloatForKey(key, defaultValue) |
float |
getDoubleForKey(key, defaultValue) |
double |
getStringForKey(key, defaultValue) |
string |
Setters write or update a value:
| Method | Type |
|---|---|
setBoolForKey(key, value) |
bool |
setIntegerForKey(key, value) |
int |
setLongForKey(key, value) |
long |
setFloatForKey(key, value) |
float |
setDoubleForKey(key, value) |
double |
setStringForKey(key, value) |
string |
removeKey deletes a stored entry:
virtual void removeKey(const char* key)
AdMob integration¶
The following methods are available on Android and iOS when the Google AdMob SDK is linked. They are no-ops on other platforms.
| Method | Description |
|---|---|
initializeAdMob(childDirected, underAge) |
Initialize the AdMob SDK. |
setMaxAdContentRating(AdMobRating rating) |
Set COPPA-compliant content rating. |
loadInterstitialAd(adUnitID) |
Pre-load an interstitial ad. |
isInterstitialAdLoaded() |
Returns true when the ad is ready to show. |
showInterstitialAd() |
Display the loaded interstitial ad. |
AdMobRating¶
- General — Suitable for all audiences.
- ParentalGuidance — Parental guidance suggested.
- Teen — Suitable for teens.
- MatureAudience — Mature content.
CrazyGames integration¶
Methods for the CrazyGames web SDK. Only active on HTML5 builds.
| Method | Description |
|---|---|
initializeCrazyGamesSDK() |
Load and initialize the CrazyGames SDK. |
showCrazyGamesAd(type) |
Show a mid-game or rewarded ad. |
happytimeCrazyGames() |
Signal a positive gameplay moment. |
gameplayStartCrazyGames() |
Notify the SDK that gameplay started. |
gameplayStopCrazyGames() |
Notify the SDK that gameplay stopped. |
loadingStartCrazyGames() |
Notify the SDK that loading started. |
loadingStopCrazyGames() |
Notify the SDK that loading finished. |