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
- Download the iOS SDK XCFramework
- Download the Cocos2dx bridge files
Add to your Cocos2d-x project
- Add the Framework and bridge files to the iOS platform code directory of your Cocos2d-x project
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 SDKgetString()- Get translation stringupdateLanguage()- Switch languagesetLogEnable()- Toggle loggingsetTranslationPreparedCallback()- Set initialization callbackevaluateString()- Evaluate stringupdateUserInfo()- Update user info
Additional Dependencies
In project settings target → General → Linked Frameworks and Libraries, add:
MediaPlayer.frameworkGameController.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.