Question

I've downloaded and installed cocos2dx 3.0 on my computer and made a new project. I'm able to compile for both iOS and Android successfully. However, I made some code changes in the HelloWorldScene.cpp and compiled these changes in Xcode. I saw the changes and everything seemed to work. I then opened the project in eclipse and compiled and ran on my nexus 7, however my nexus did not see the changes that the iOS version did. I then noticed that the Classes folder is empty in eclipse. This folder should contain the .cpp .h files for the C++ game logic. I've gone through quite a few tutorials and google searches but the documentation is inconsistent as it seems the folder and project structure for cocos2dx is slightly different between cocos 2.x versions and version 3.0.

**Steps I've tried

  1. Created new project: drilled down to cocos2d-console/bin Executed cocos.py new TestGame -p com.test.testgame -l cpp -d ~/
  2. At this point, new multi platform game is created. (I'm putting all my folders on my desktop for the game, cocoas, and android ndk, also I have all the c/c++ tools setup for Xcode as well as gdb setup too I'm on mac using mavericks to I had to manually set that up since no longer included.)
  3. I go into GameFive->prog.ios_mac and open the game in xocde, it runs just fine, make changes to the .cpp game files, and they show up in the simulators etc.
  4. Now the eclipse part. I follow the instructions in the proj.android README.md in my TestGame directory.
  5. I create the Path Variables Eclipse->Preferences->General->Workspace->LinkedResources: "New" and give it the path to my COCOS2dx3.0 folder directory which is on my desktop
  6. I then create the second path variable NDK_ROOT by doing: Eclipse->Preferences->C/C++->Build->Environment "Add" "New". I give the variable Name: NDK_ROOT and value points to the android-ndk-r9d folder sitting on my desktop.
  7. At this point I compile build the libcocos2dx library by chaining to the cd to TestGame/proj.android then export NDK_ROOT=/Users/me/android-ndk-r9d after that I do ./build_native.py and this builds the libcocos2dx library
  8. Now I go back to eclipse, and import libcocos2dx and TestGame as existing android applications into eclipse. I find the libcocos2dx in TestGame/cocos/2d/platform/android/java and I import this. I import my game by including TestGame/proj.android into eclipse.
  9. At this point, everything builds in eclipse, and I can run the project on my nexus. But the "Classes" and "cocos2dx" folders in eclipse are empty after executing the above instructions in that order. If anyone has any help or suggestions it would be greatly appreciated. I've spent way too much time trying to figure out things that should work out of the box. Thanks!
Was it helpful?

Solution

Right click on the Classes folder. Go to properties. Pick Resources from the left.

Click on Edit to edit the link. A window will pop out. Browse to your game folder and then select classes from the folder. Click Ok and you must see the files!

However, as far as compiling is concerned, every changes that you make in the CPP files needs to be compiled through the build_native.py command for Android. That is to say:

  • Make a change in a CPP file.
  • Open terminal
  • CD to your game/proj.android
  • type python build_native.py. for example:

    cd /home/kasra/Desktop/testgame/MyGame/proj.android/

    python build_native.py

Remember to do this step everytime after you make any change! I have not found an easier way. But I am searching for it. It should have something to do with C++ builder. If I find anything I will post it here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top