Project setup and initialization
General setup: Managed
Add the Scoreloop library into your project as a first step.
- Right click Project properties
- Go to C/C++ build -> Settings -> Tool Settings -> QCC Linker -> Libraries
- Add "scoreloopcore" to Libraries (-l)
General setup: Makefile
Add the Scoreloop library to the common.mk file in your project.
LDFLAGS += -lscoreloopcore
Modify the application's ".pro" file to include LIBS += -lscoreloopcore
Take a look at our Sample Code before you build your project. Our repository is frequently updated with samples to help you!
This section outlines the first steps toward integrating the Scoreloop SDK into your application.
Initialization consists of the following steps:
Step 1: Register your game with Scoreloop (if you haven't already):
- Visit the Developer Website.
- Register your game to obtain your game-specific data (game id, game secret, and game-specific currency code).
Step 2: Include the following Scoreloop header file in your application (the file that contains all files that use Scoreloop API).
Step 3: Create an instance of the SC_ClientConfig class. In the initialization of your application, create a SC_ClientConfig and set the game specific parameters. SC_ClientConfig is then used to create an instance of SC_Client. You must supply the following information to the SC_ClientConfig instance:
- game id, secret, and game-specific currency that you received on registering your game with Scoreloop
- current game version
- list of languages supported
Sample code for creating the SC_ClientConfig instance:
SC_ClientConfig_h clientConf; // create an instance of the SC_Client_Config class SC_ClientConfig_New(&clientConf); // aGameId is the unique game identifier (const char string that you obtain from Scoreloop). SC_ClientConfig_SetGameIdentifier(clientConf, aGameId); // aGameSecret is the unique game secret (const char string that you obtain from Scoreloop). SC_ClientConfig_SetGameSecret(clientConf, aGameSecret); // aCurrency is the unique game currency code (const char string that you obtain from Scoreloop). SC_ClientConfig_SetGameCurrency(clientConf, aCurrency); // aGameVersion should be your current game version. SC_ClientConfig_SetGameVersion(clientConf, aGameVersion); // aLanguageCode specifies the language support for localization in awards. // Its a comma-separated list of languages the game supports. e.g., for English, pass "en" SC_ClientConfig_SetLanguages(clientConf, aLanguage);
Step 4: Create the Scoreloop client instance.
- In the initialization of your application, create the Scoreloop client instance by calling SC_Client_NewWithConfig().
Step 4 sets up the underlying infrastructure necessary to use Scoreloop in your game. An instance of the client should persist for the lifecycle of your game.
Only local game play is possible in CORPORATE LIABLE MODE. Here, the device forbids the use of Scoreloop. A connection request returns error code SC_DISABLED_DUE_TO_CORPORATE_LIABLE_MODE that needs to be handled and a suitable message displayed to the user.
A first time setup of the Games app will allow your game to post activities on it. If a user hasn’t setup the Games app on the device yet and starts your game, it will trigger the setup process of the Games app. Once the user finishes this setup, he will automatically return to your game. This mechanism requires that your game has posted a window; otherwise your game may be slayed by the operating system.
- Before calling SC_Client_New a window needs to be posted. When no window is posted, your application could be slayed by the system as SC_Client_New might block for an unbounded amount of time.
- Your game will not be brought to the foreground automatically, without a window posted beforehand.
- Posting a window depends on the application environment (core native, Cascades) you use. Please check the respective documentations on how to post a window in your environment. For example, with core native you would have to call screen_post_window() first, with Cascades you would have to wait for the posted() signal of Application::mainWindow().
- In case the user chooses not to complete the Games app set-up, disable Scoreloop functionality (grey out the Scoreloop options on the menu with appropriate message) in your app. Posting a window as described above will get the user back to your app after hitting 'cancel' in the Games app set-up.
Sample code for creating the client instance:
SC_Error_t errCode; SC_Client_h client; // clientConf is the clientConfig instance created in step 3 SC_Client_NewWithConfig(&client, clientConf);
Once the SC_Client instance is created, you may want to release the SC_ClientConfig instance that was created, by calling SC_ClientConfig_Delete().
When creating the SC_Client the user might be prompted to enter BlackBerry ID credentials.
Once the initialization is complete, you can integrate the Scoreloop features of your choice into your game.
Step 5: Release Scoreloop resources before closing your application.
Last modified: 2014-05-14