-
-
Notifications
You must be signed in to change notification settings - Fork 209
Cocos2d‐x migration guide
Migrating from Cocos2d-x to Axmol Engine is straightforward. You will need to change the namespace form USING_NS_CC
to USING_NS_AX
, and check the Renamed Types section in this same page in order to solve the errors that may appear.
For converting Cocos2d-x v4.0 projects to Axmol Engine, it may be convenient to use the axmol-migrate
tool to alleviate some workload. Please be aware this is only for convenience, not mandatory, and also older versions of Cocos2d-x (v3.x and older) may not work at all.
This is how it works:
For quick fixing the header's includes of your project source code:
- Clone https://github.com/axmolengine/axmol-migrate
- Go to folder
axmol-migrate
and runpwsh ./build.ps1 -xb "'--config', 'Release'"
- Use
axmol-migrate
to migrate your project sources folder./build_x64/bin/Release/axmol-migrate source --fuzzy --source-dir path/to/your/project/sources/folder
Notes: The command line axmol-migrate.exe
can fix 99% (or 100% for some projects) of your includes. After executing it, you can manually fix any compile error. The axmol-migrate
can compile on Windows, MacOS and Linux.
All the Cocos2d-x methods that do the same function than the Standard Template Library in modern C++ has been deprecated. For example, for CCString
please use std::string
instead, etc.
Axmol uses the ax
namespace, which replaces the cocos2d
namespace.
The <Axmol>/core/cocos2d.h
header file is provided for convenience, and contains a number of Cocos2d-x to Axmol mappings for the namespace, existing types and macros. It can be used via #include "cocos2d.h"
to ease migration, although it would be best to update the code over time to the Axmol naming for the sake of future compatibility and maintenance of a project.
-
RngSeed
=> FastRNG UNDERmath/FastRNG.h
-
Sprite3D
=> MeshRenderer UNDER3d/CCMeshRenderer.h
-
Sprite3DMaterial
=> MeshMaterial UNDER3d/CCMeshMaterial.h
-
Director::isDisplayStats()
=> Director::isStatsDisplay() UNDERbase/CCDirector.h
-
FileUtils::createDirectory
=>FileUtils::createDirectories
-
FileUtils::getFileShortName
=>FileUtils::getPathBaseName
-
FileUtils::getFileExtension
=>FileUtils::getPathExtension
If you need to use common extensions, such as Spine, Live2D, FairyGUI, Effekseer etc., then the extensions that are included with the Axmol source can be enabled via cmake options. Refer to this page for more information.
Axmol 2.x now utilizes glslcc to compile shaders for each renderer backend (OpenGL, Metal etc.). Please check the wiki page Shaders in Axmol for more detailed information. The changes were originally described in issue 1279.