Cocos2d-x basics

Some articles about Cocos2d-x framework

Project structure

Posted at — Sep 22, 2020

You may have already noticed that even the basic cocos2d-x project takes a lot of space on hard drive. The situation was even worse with older versions of framework; it could use almost 1GB for small project. Some people think it’s not that significant, but just weird when you have a lot of projects and suddenly run out of space.

A typical cocos2d-x project looks like this:

SmokeTest
|-bin
|-Classes
  |-AppDelegate.cpp
  |-AppDelegate.h
  |-HelloWorldScene.cpp
  |-HelloWorldScene.h
|-cocos2d
  |- <a lot of files and folders>
|-linux-build
  |- <some other files and folders>
|-proj.ios_mac
|-proj.win32
|-proj.android
|-proj.linux
  |-main.cpp
|-Resources
|-CMakeLists.txt

Here:

Finally, the CMakeLists.txt is a typical cmake file for your project. If you never dealt with cmake earlier don’t worry, the only important thing there is list of source files. It looks like this:

# add cross-platforms source files and header files
list(APPEND GAME_SOURCE
     Classes/AppDelegate.cpp
     Classes/HelloWorldScene.cpp
     )
list(APPEND GAME_HEADER
     Classes/AppDelegate.h
     Classes/HelloWorldScene.h
     )

And that’s all for now.