Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class GameServices
- Object
- GameServices
The gaming platform the application runs under: achievements, stats, cloud saves, the signed in player and their presence.
One API for every platform. The first backend is Steam (the steam build
target); others plug in behind the same calls. Everything here is safe to
call everywhere: with no platform, or one that has not connected,
#isAvailable() is false and every call does nothing and answers its
default, so a game needs no platform checks around it.
GameServices.unlockAchievement("FIRST_WIN");
GameServices.setStat("wins", GameServices.getStatInt("wins", 0) + 1);
GameServices.commit();
Identifiers are the ones configured with the platform (on Steam, the API names entered in the Steamworks partner site).
Pausing. Register a GameServicesListener to hear when the platform’s
own interface (the Steam overlay) opens over the game; pause while it is up.
Call from the EDT.
Methods
Inherited methods
Method details
setBackend
public static void setBackend(GameServicesBackend b)getPlatformName
public static String getPlatformName()"steam"), or an empty string when there is none.isAvailable
public static boolean isAvailable()getPlayerId
public static String getPlayerId()getPlayerName
public static String getPlayerName()unlockAchievement
public static boolean unlockAchievement(String id)#commit().resetAchievement
public static boolean resetAchievement(String id)isAchievementUnlocked
public static boolean isAchievementUnlocked(String id)getStatInt
public static int getStatInt(String id, int def)def when unknown.setStat
public static boolean setStat(String id, int value)#commit().getStatFloat
public static float getStatFloat(String id, float def)def when unknown.setStat
public static boolean setStat(String id, float value)#commit().commit
public static boolean commit()isCloudSaveAvailable
public static boolean isCloudSaveAvailable()writeSave
public static boolean writeSave(String name, byte[] data)readSave
public static byte[] readSave(String name)hasSave
public static boolean hasSave(String name)deleteSave
public static boolean deleteSave(String name)setPresence
public static boolean setPresence(String key, String value)key is a rich
presence key ("status" is shown as is).clearPresence
public static boolean clearPresence()ownsContent
public static boolean ownsContent(String id)openPlatformUI
public static boolean openPlatformUI(String target)target names a page:
on Steam one of the overlay dialogs ("friends", "achievements",
"stats", "community", "settings") or an https:// URL. Answers
false when the platform has no such interface.isControllerFirst
public static boolean isControllerFirst()getLanguage
public static String getLanguage()"english", "german"…), or an empty string.addListener
public static void addListener(GameServicesListener l)removeListener
public static void removeListener(GameServicesListener l)firePlatformUIChanged
public static void firePlatformUIChanged(boolean shown)