Cocos2d-x support for Nakama

Author profile
April 2, 2019
Featured image

We’ve had significant demand of late to provide an open-source client library for Cocos2d-x from the community to integrate with Nakama. I’m very pleased to announce a bespoke Cocos2d-x C++ client library. You can find it open-sourced on GitHub and our documentation here.

As with all Nakama client libraries, we ensure full compatibility with the feature set of Nakama in order to power games of all types — from realtime battlers to turn-based strategy style games. Some of the features include:

  • Client-authoritative and server-authoritative multiplayer.
  • Complex Matchmaing
  • Tournaments / Leaderboards
  • Friends and Clans
  • Social Login
  • User accounts and Storage and much, much more

We’ve made the client library as intuitive as possible. Here are a few code snippets from our documentation to demonstrate:


auto loginFailedCallback = [](const NError& error)
auto loginSucceededCallback = [](NSessionPtr session)
std::string deviceId = “unique device id”;


int port = 7350; // different port to the main API port
bool createStatus = true; // if the server should show the user as online to others.
// define realtime client in your class as NRtClientPtr rtClient;
rtClient = client->createRtClient(port);
// define listener in your class as NRtDefaultClientListener listener;
 // Socket connected
rtClient->connect(session, createStatus);

Send Requests:

auto successCallback = [](const NAccount& account)
 CCLOG(“user id : %s”,;
 CCLOG(“username: %s”, account.user.username.c_str());
 CCLOG(“wallet : %s”, account.wallet.c_str());
client->getAccount(session, successCallback, errorCallback);

The server itself is fully open-source and we welcome any and all contributions! We have games running on Nakama that exceed over 30 billion API calls per month with some of our partner studios. The goal of Nakama has always been to democratise game development so that teams of any size, including indie developers or AAA studios can build their dream games without worrying about scalability and reliability on the backend.

Our team will be attending Quo Vadis in Berlin and Reboot Conference in Dubrovnik in April as well as PG Connects Seattle in May. If you’d like to meet up with us, feel free to reach out to us and we can arrange a time to meet.

Speak to the Heroic Labs team

Do you have any questions about this blog post or would you like to find out more about any of our products or services?