Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocos2dX, Assets getting deleted on Build or Run (Eclipse Juno, Android C++ project)

Could someone please advise where and how to add assets to an Android Cocos2D-X project. I've tried both just linking the assets to the 'assets folder' in Eclipse as well as physically placing a copy of the assets in the assets folder via file system where the project is located. But when I build or run the project in Eclipse the assets are deleted. I've also tried tried running the 'build_native.sh' then running the projectt in Eclipse as other posts on the this site have suggested but in all cases the assets get deleted.

IS there another location that I need to place my assets. Also do I need to manually add them in a config file within the project (e.g.: the manifest file).

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

Please advise.

like image 537
badboy11 Avatar asked Jan 18 '13 18:01

badboy11


2 Answers

You have Resources folder in your folder structure as you can see in HelloCpp or any example project. Thats where you have to put your images etc..

And regarding assets you do not need to do anythng just run build_native.sh, Assets folder will get generated by its own in the proj.android folder.

to know more just open build_native.sh in that there are three lines which says copy resources to assets folder

I hope you got your answer Good Luck : If further queries please feel free to ask.

like image 84
user1169079 Avatar answered Sep 22 '22 07:09

user1169079


The DETAILED explanation. You need to put the image file you want to use into the "Resources" folder of the Cocos2DX project you are running. Then you need to run ./build_native.sh from the Cygwin program.

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

  1. Place all the image files (sprite.png, *.png) you want to use inside the "Resource folder".
  2. Open Cygwin as administrator and navigate to the c:/cocos2dx/cppgame/proj.android/ folder.
  3. Type "./build_native.sh" into the Cgywin prompt ("$").

This should put all of your image files into the assets folder of your project and now you can use them to create sprites!

EXPLANATION: The build_native.sh file copies the image files to the assets folder and sets some special permission so they don't get deleted when you run the program. If someone with a better understanding of cygwin coding can explain it better, I'd be grateful.

like image 43
Neo Smith Avatar answered Sep 21 '22 07:09

Neo Smith