Skip to content

Cocos2d‐x migration guide

Grif_on edited this page Mar 1, 2024 · 17 revisions

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.

If in your Cocos2d-x project you're including engine headers different from cocos2d.h (or axmol.h), it's recommended to follow this steps for quick fixing the header's includes of your project source code:

  1. Clone https://github.com/axmolengine/axmol-migrate
  2. Go to folder axmol-migrate and run pwsh ./build.ps1 -xb "'--config', 'Release'"
  3. 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.

Renamed Types

All the Cocos2d-x methods that make the same function than the Standard Template Library in modern C++ has been deprecated. For example, for CCString please use std::string instead, etc.

Classes & Structs

  • RngSeed => FastRNG UNDER math/FastRNG.h
  • Sprite3D => MeshRenderer UNDER 3d/CCMeshRenderer.h
  • Sprite3DMaterial => MeshMaterial UNDER 3d/CCMeshMaterial.h

Functions & Methods

  • Director::isDisplayStats() => Director::isStatsDisplay() UNDER base/CCDirector.h