Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:Cocos2d-x

From ReverseEngineering.wiki
Library
Developer Chukong Technologies / Xiamen Yaji (Cocos)
License MIT
Website https://www.cocos.com
On this wiki Facts · Code · Notes · Topics

The MIT-licensed C++ 2D game engine (and its successor Cocos Creator's native runtime): recognisable by a cocos2dVersion() string, plist-based sprite sheets and, in script-based games, a .jsc script container.

Overview

Two code bases share the name. cocos2d/cocos2d-x (C++, MIT) is the classic engine; cocos/cocos-engine is the engine of Cocos Creator (TypeScript plus a C++ native layer in native/, MIT, package.json version 3.8.9 at the commit read). Sources read: cocos2d-x commit 7a5282a301a13e467bdcc3466d3cd3883862aadf, cocos-engine commit 4bbfb6f521936e87284cf5b3e59e6b8139411d7e.

Recognising it

  • cocos2d-x: the function cocos2dVersion() (cocos/cocos2d.cpp) returns the string cocos2d-x-4.0 in the v4 tree, so that literal in a binary dates the engine; older tags return cocos2d-x-3.17.2 (tag cocos2d-x-3.17.2, commit 1528ea01d2749b4ef65e97f79cffa6135fe13c4d, cocos/cocos2d.cpp line 35) and cocos2d-x-3.10 (tag cocos2d-x-3.10, commit 67f4be538b96f9506c30e56e7e5266c0b34e9d26, line 34), while 2.x returns cocos2d-x 2.2.6 with a space instead of a hyphen (tag cocos2d-x-2.2.6, commit 1fc007df0ed6f01ef458083504260d0752d19049, cocos2dx/cocos2d.cpp line 33) and defines COCOS2D_VERSION 0x00020206 in cocos2dx/include/cocos2d.h.
  • Libraries are named libcocos2d (libcocos2d.so on Android, cocos2d.dll on Windows). Unverified (not read in source).
  • Resource files are loaded through CCFileUtils; property lists (sprite sheet .plist, particle .plist, animation .plist) are Apple XML plists parsed with tinyxml2 (CCFileUtils.cpp), see Format:Property list (binary bplist00) for the binary form.
  • Cocos Creator 3.x JavaScript games ship .js or .jsc files. The native ScriptEngine (native/cocos/bindings/jswrapper/sm/ScriptEngine.cpp) defines BYTE_CODE_FILE_EXT = ".jsc", and a source comment states that since Creator v1.7 a .jsc file is not SpiderMonkey bytecode any more but an XXTEA encrypted binary format. The wiki does not document keys or decryption. If a .jsc file does not begin with a recognisable bytecode magic, assume this container before assuming a bytecode format.

ccbi and other formats

.ccbi files are read by the CCBReader class: it exists in cocos2d-x 2.2.6 as extensions/CCBReader/CCBReader.cpp and in 3.17.2 as cocos/editor-support/cocosbuilder/CCBReader.cpp (it is absent from the 4.0 tag tree). In 3.17.2 the reader (CCBReader.cpp lines 354-382) loads a string cache and checks the first four bytes against the text ccbi, then a version number against CCB_VERSION, which CCBReader.h line 64 defines as 5; a mismatch only logs "Incompatible ccbi file version". Commit 1528ea01d2749b4ef65e97f79cffa6135fe13c4d. Unverified: that the files are produced by the CocosBuilder editor (not part of this repository).

Related

Library:Lua (cocos2d-x Lua games), Library:V8, Format:Lua bytecode.

Code & repositories

  • https://github.com/cocos2d/cocos2d-x @ 7a5282a301a13e467bdcc3466d3cd3883862aadf · license: MIT (declared by the contributor; GitHub's detector did not recognize a license file)
    cocos2d-x C++ engine v4
    Tested on: source read, not run: source only · checked 2026-10-18
  • https://github.com/cocos/cocos-engine @ 4bbfb6f521936e87284cf5b3e59e6b8139411d7e · license: MIT (declared by the contributor for the files used; GitHub reports MIT (read from LICENSE.md; GitHub's API was busy) for the repository)
    Cocos Creator engine; native ScriptEngine handles .jsc
    Tested on: source read, not run: source only · checked 2026-10-18