Hi Every one.
First of all thank you for providing such a great platform to work on android.
After working hard for last two months i completed a game of TRON on win32 using cocos2d-x which is running very perfectly on windows.
then i decided to port the game on android. So started as…
I am using cocos2d-1.0.1-x-0.9.1.
I unzipped it in “g” drive. and renamed the folder as cocos2d-x. so my root directory is
> g:/cocos2d-x>setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // I Just added this line here and orientation was fixed……
I have android-ndk-r6 in “e” drive ie, e:/android-ndk-r6/
I have cygwin 1.7 installed perfectly.
I have default .mk files that came with cocos2d-1.0.1-x-0.9.1.
Now i tried making HelloWorld to run on android and my build_native.sh paths are…
It got compiled with cygwin and build all .so files and after exporting it on eclipse it was working fine but there was orientation problem so i researched over net and found solution to fix it as…
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
#endif // CC_PLATFORM_IOS
Now i have HelloWorld running perfectly fine on emulator and i m able to run tests also on emulator…so far so good.
Now i tried doing the same thing with my Tron Game but it was not getting compiled through cygwin (may be because of paths in android.mk). So i added all my game class files to the HelloWorld Classes and modified AppDeligate as:
// create a scene. it’s an autorelease object
CCScene pScene = MainMenu::constructScene;
and i got my game running perfectly fine on windows from HelloWorld project…every thing is fine till here.
Now i thaught if HelloWorld alone was working on android fine so it should also work.
So i modified the android.mk file in G:2d-x\HelloWorld\android\jni\helloworld as,
LOCAL_PATH := $
LOCAL_MODULE := helloworld
LOCAL_SRC_FILES := main.cpp …/…/…/GameController.cpp …/…/…/MainMenuScene.cpp …/…/…/GamePlayScene.cpp …/…/…/Grid.cpp …/…/…/Tile.cpp …/…/…/Tron.cpp …/…/…/AppDelegate.cpp
LOCAL_C_INCLUDES := $/…/…/…/…/cocos2dx $/…/…/…/…/cocos2dx/platform $/…/…/…/…/cocos2dx/include $/…/…/…/…/cocos2dx/lua_support $/…/…/…/…/CocosDenshion/include $/…/…/…
# it is used for ndk-r5
# if you build with ndk-r4, comment it
# because the new Windows toolchain doesn’t support Cygwin’s drive
LOCAL_LDLIBS := ~~L$/…/…/libs/armeabi) ~~lcocos2d
and kept everything as it is.
now as yo can see my cpp files, i have 6 classes apart from AppDeligate.cpp and the execution takes place as follows,
AppDeligate.cpp starts running MainMenuScene as : CCScenepScene = MainMenu::constructScene(); , pDirector->runWithScene(pScene);
and MainMenuScene.cpp displays two button “Start Game” and “Exit”. Now when you click on “Start Game” the execution goes like this,
and i get my GamePlayScene running . This scene runs my whole game which runs perfectly fine on windows. So in my game i have only two scenes MainMenuScene and GamePlayScene and the game is working fine on my PC.
Now coming back to android…
the same way i compiled my game as HelloWorld using cygwin 1.7 and got all .so files.
i exported the game on emulator using eclipse (Indigo)…and…
THE GAME STARTED…
I WAS VERY HAPPY TO SEE MY MAIN MENU SCREEN ON EMULATOR…
but every thing goes down when i click on “StartGame”…
As I clicked on “StartGame” the scene is suppose to change from MainMenuScene to GamePlayScene…and i think it started to change…but suddenely it got crash by sayin…
UNABLE TO GET DATA (GamePlayBg.png) FROM ASSETS. and exits to emulators main screen.
i rebuilded the project/recompiled in cygwin/refreshed eclipse completely/build fresh .so and apk file…and tried again two three times but nothing happened same bud…
I tried using GamePlayBg.png in my first MainMenuScene as background (in place of “MainMenuBg.png”). so in first the GamePlayBg.png is coming in first scene (MainMenuScene) as background but as soon as click on “Start Game” button same bug comes again.
i checked the .apk in winRAR and all the resources are present there needed in the game.
I m not able to understand that it is able to add GamePlayBg.png in the first scene but crashes when tried to add the same sprite in second scene…why is that.
WHERE I AM DOING WRONG PLEASE SUGGEST ME…
I want to have my game on android…Please help me this is the last thing in my game.