Skip to content

Cocos2dx Engine Integration

Note: Cocos2d-x is an open-source, cross-platform game development framework supporting iOS, Android, Windows, and more. If you are developing an iOS app with Cocos2d-x, you need to use the Cocos2dx bridge files provided by the iOS SDK.

Integration Steps

  1. Download the iOS SDK XCFramework
  1. Download the Cocos2dx bridge files
  1. Add to your Cocos2d-x project

    • Add the Framework and bridge files to the iOS platform code directory of your Cocos2d-x project
  2. Use in Cocos2d-x C++ code

cpp
#include "LoxilyLocalizeCocos2dx.h"

// Initialize SDK
LoxilyLocalizeCocos2dx::init("YOUR_APP_KEY", "zh-cn", true, false);

// Get translation string
std::string text = LoxilyLocalizeCocos2dx::getString("110100", "Default text");

// Switch language
LoxilyLocalizeCocos2dx::updateLanguage("en");

Available Methods

The LoxilyLocalizeCocos2dx class provides the following static methods:

  • init() - Initialize SDK
  • getString() - Get translation string
  • updateLanguage() - Switch language
  • setLogEnable() - Toggle logging
  • setTranslationPreparedCallback() - Set initialization callback
  • evaluateString() - Evaluate string
  • updateUserInfo() - Update user info

Additional Dependencies

In project settings targetGeneralLinked Frameworks and Libraries, add:

  • MediaPlayer.framework
  • GameController.framework

Note: Cocos2dx bridge files are part of the iOS SDK and provide a C++ class interface, allowing Cocos2d-x C++ code to call iOS SDK functions.