Useful 3rd party libraries for development in cocos2d-x

Posted by | No Tags | Company life | No Comments on Useful 3rd party libraries for development in cocos2d-x

In our game, player data are stored in sqlite3 while level configs as JSON. For porting the program, we had to find the corresponding function libraries. The description below are based on the sample project environment we created in our two former blog entries here and here.

1. sqlite3 c library

This function library is already included in cocos2d-x 2.1.1, still, we separately implemented it in our project (We ignored the option for the set of JNI calls when querying SQLite as cocos2d-x LocalStorage do).

First, download the zipped source files from here and unzip all of them except shell.c to the Classes/Extensions (or Third Party etc) folder of our project. By doing so, they will also be included in our project so from now on we can use them freely.

(If you use your own compiler script instead of ours, the name of the sqlite3.c file must be appended to the jni/ LOCAL_SRC_FILES variable.)

We will see that during compilation, the robust sqlite3 function library will also be compiled (very, very slooowly but we will show you a trick to speed this up later).

For a brief example on how to use it go here. We too wrote a bit more extensive wrapper class around sqlite3 for quicker use, which we will show you through examples in a later blog entry.

2. cJSON

The name of the function library speaks for itself: it enables JSON processing with C functions. We opted for this method because we ignored the option for the set of JNI calls during JSON processing.

We chose the cJSON function library, which can be downloaded from here.

Unzip the files cJSON.h and cJSON.c to the Classes/Extensions/cJSON folder.

This (like every source file included) will further slow down the compilation process but our speed-up “trick” will solve this issue too.

The use of cJSON is explained through examples in the README file of the downloadable zip archive. Based on this, we wrote a wrapper class to simplify the work with JSON objects. Yep, we are great fans of wrapper classes 🙂

In another blog entry, we will describe this class in detail too.


We introduced two function libraries that are extremely useful or even indispensable in our applications.
However, implementing them will slow down the compilation time of our project. We will show you a solution to this in our next blog entry.

Happy coding!

No Comments

Leave a comment