GamesChart Android API Implementation - IDE

Implement the GamesChart API using the IDE method by following 2 simple steps: {|

Step 1 - Including the jar file
The entire GamesChart API is contained in 1 small jar file. This needs to be included in your application. You will find the latest API jar file in the GamesChart Developer Pack. There are a couple of standard ways to include external jar files. These are not GamesChart specific operations, so whichever method you’re most comfortable with is just fine. Your Project > (Right Click) Import > File System > (Browse to) GamesChartAPI.jar Your Project > (Right Click) Properties > Java Build Path > Libraries > Add Jar > (Browse to) GamesChartAPI.jar

Step 2 - AndroidManifest.xml
Locate your AndroidManifest.xml file Find the following line, and make sure you set the android target sdk version to 8. This enables us to correctly determine the screen resolution of the device we're running on.  Next add the required permissions. Below is the complete list of permissions that the GamesChart API requires, so add as many as you need.      Finally, add the following line after your activity block:  A complete AndroidManifest.xml should look something like this, once the GamesChart entries have been added:      </uses-permission> </uses-permission> </uses-permission> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:name=".Vortex" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <activity android:name="com.gcapi.GamesChart">

Step 3 - Code Setup
We can begin the set-up procedure. You should have something like this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Add the following code AT THE END of your onCreate block. Remember, order is important here. GamesChart needs to appear on top of everything else in your game, so it must be added at the end of your setup procedure.

/////////////////////////////////////////////////////////////////////////////////////////////////////// // STEP 1: INITIALISE GAMESCHART SYSTEM /////////////////////////////////////////////////////////////////////////////////////////////////////// String gameID = "bc055fe4f21c9617e6463b7c0ecc7101"; // provided to you when you register your game GamesChart.setup(this, gameID); Next, GamesChart needs to know that you're ready to start the loading process. This process can take a few seconds to check for connections and load assets and data, so we recommend doing it at a sensible time, perhaps when you show a splash page or company logo during loading. If you forget to add this step, GamesChart will fire it up on the first touch event it receives. /////////////////////////////////////////////////////////////////////////////////////////////////////// // STEP 2: TELL GAMESCHART THAT GAME IS READY /////////////////////////////////////////////////////////////////////////////////////////////////////// GamesChart.gameStarted; Ok, just one more line to handle events and we're done.

Locate your onTouch method and add the following line AT THE END of the method /////////////////////////////////////////////////////////////////////////////////////////////////////// // STEP 3: INFORM GAMESCHART OF EVENTS (with optional code for pausing your game) ///////////////////////////////////////////////////////////////////////////////////////////////////////

// OPTIONAL - check to see if GamesChart has been opened if (GamesChart.openChart(event)) { // pause your game here if required } // OPTIONAL - check to see if GamesChart has been closed else if (GamesChart.closeChart(event)) { // un-pause your game here if required }

// MANDATORY - check all GamesChart events GamesChart.checkEvents(event); Locate your onDestroy method and add the following code. /////////////////////////////////////////////////////////////////////////////////////////////////////// // STEP 4: HANDLE APP DESTRUCTION AND PAUSING ///////////////////////////////////////////////////////////////////////////////////////////////////////

// MANDATORY - check all GamesChart events GamesChart.pauseApp;

Additional GamesChart Functionality
If you’re happy with the way GamesChart looks and works, great, you don’t need to do anything else. However, if you want to change the way GamesChart works for you, we’ve created some additional functions for you to use. These functions may be called at any point you like during your game flow. Open / Close Charts If you would like to control when the Charts are displayed in your game; at “Level Complete” or “Game Over” for example, you can simply use the open and close methods. GamesChart.openCharts; // forces the charts to be displayed

GamesChart.closeCharts; // forces the charts to be closed again