Cocos2dX, Assets deleted at build or run (Eclipse Juno, Android C ++ project)

Can someone please tell where and how to add assets to the Cocos2D-X Android project. I tried to simply associate assets with the "asset folder" in Eclipse, and physically place a copy of the assets in the resource folder through the file system where the project is located. But when I create or run a project in Eclipse, the assets are deleted. I also tried running "build_native.sh" and then running the project in Eclipse, as other posts on this site suggested, but in all cases the assets are deleted.

Is there any other place where I need to place my assets. Also I need to manually add them to the configuration file inside the project (for example: manifest file).

My system: Mac OS Lion Eclipse Juno Cocos2D-X v2.1 Beta 3

Please inform.

+6
source share
3 answers

You have the β€œResources” folder in the folder structure, as you can see in HelloCpp or in any example project. Thats where you should put your images etc.

And with regard to assets, you do not need to do anything, just run build_native.sh, the Assets folder will be generated independently in the proj.android folder.

to find out more, just open build_native.sh, which has three lines that say copy resources to the resource folder

I hope you got your answer. Good luck: If you want to continue, please feel free to ask.

+4
source

DETAILED explanation. You need to put the image file that you want to use in the Resources folder of the Cocos2DX project that you are using. Then you need to run. / build _native.sh from Cygwin.

EXAMPLE: You create a game called cppgame. You create a cppgame project with the Create-android-project.bat file in the Cocos2DX folder. Now you have the cppgame project folder on c: c: / cocos2dx / cppgame /. In this folder, you have the "Resource" folder, which was also created (c: / cocos2dx / cppgame / Resources /).

  • Place all the image files (sprite.png, * .png) that you want to use in the Resources folder.
  • Open Cygwin as an administrator and navigate to c: /cocos2dx/cppgame/proj.android/.
  • Enter "./build_native.sh" at the Cgywin prompt ("$").

This should put all your image files in the folder with the resources of your project, and now you can use them to create sprites!

EXPLANATION: the build_native.sh file copies image files to the resource folder and sets special permission so that they are not deleted when the program starts. If someone with a better understanding of cygwin coding can explain this better, I would be grateful.

+2
source

Its own simple batch script (batch_native.py), which copies resources from the multi-platform Resource folder (used in cocos2d-x templates) to the resource folder used on Android.

One Step Solution: Just copy all your images Name-sd.png, imageName-hd.png, etc. In the resource folder.

Happy programming :)

batch_native.py that copy files to the Android resources folder.

# copy resources for file in "$APP_ROOT"/Resources/* do if [ -d "$file" ]; then cp -rf "$file" "$APP_ANDROID_ROOT"/assets fi if [ -f "$file" ]; then cp "$file" "$APP_ANDROID_ROOT"/assets fi done 
0
source

All Articles