Port iphone game to android in C++

I have a game written using objective C and cocos2d.
I want to port it to android without using java.

I initially tried with airplay sdk but it has too many issues.

Is it possible to port my game using this cocos2dx and ndk in C++? and what resources will be required.

A quick reply will be appreciated. Thanks

Yes, you can port it with cocos2d-x.
If you didn’t use too many iOS sdk, it will be very easy and quick to port.

Can you just help me start out.
Any tutorials and the softwares that will be required.
I’m very short on time as I wasted alot of time with airplay.
Thanks.

I think you can start with
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_run_HelloWorld_on_ndk_r4_and_r5

After reading it, you will have set up ndk developing environment.

Then, you can read
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_create_android_project_with_script

It will help you to create an android project.

Ofcource, you can use the HelloWorld as your project, and add your codes.

I have around 800 frames in my plist file.
This was one of the major issues due to which my sprite sheet was not loading using airplay.
Will there be the same problem when using the android ndk?
Is cocos2dx stable with android ndk ? Can you send me the link of any games created using this.
Thanks.

You can use plist file as you did with cocos2d-iphone.
The games used cocos2d-x listed in http://www.cocos2d-x.org/projects/cocos2d-x/apps.

Is there any limit on the number of frames that can be in a sprite sheet.
Because the sprite sheet I was using for iphone which had around 8000 frames in it and when i loaded it using cocos2dx and airplay the application crashed. There was nothing else happening in the application. I was only trying to load this one sprite sheet and was getting memory crashes.
So that is my main concern.

Hey Minggo thanks for the help.
I’ll be bugging you if I get stuck.
thanks alot

I’ve managed to successfully port Chirp Chirp from cocos2d-iphone to cocos2d-x. I also had problems with anything to do with plist files. I wound up writing my own implementation for reading them, using tinyxml instead of libxml. Most of the crashes seemed to be happening inside libxml.

Are you able to load you 8000-frame sheet using the win32 version of cocos2d-x? If so, i’d imagine the engine can in theory handle it. If you’re getting android-only memory crashes, maybe you’re just using too much memory for your device?

Hey Isaac,
I didn’t try it for windows. The 8000 frame sheet loads up easily on normal cocos2d in objC.
It kinda crashed on android. It got stuck or something while loading.
Can you email me or attach your implementation for reading them. It will be highly appreciated. Thanks

I’d recommend trying it first on the win32 build, so you can see if its a problem with cocos2d-x or with android.

Ok cool. I’ll do that.
Thanks

I tried loading the sprite sheet using cocos2d and android sdk in java. I got a memory error. Actually someone tried it for me. The error was something like insufficient memory and the app crashed.
So that ill assume android is not capable of handling so many frames.
Well theoretically it isn’t a very good practice that I have so many frames in a single sprite sheet but if I can get this to work then my life will be soo easy.

Hey Isaac,
There is some issue with the parsing being used.
I tried to load the plist through airplay(marmalade) and got the same issue with loading it. The issue is not only on android but also iOS(if the native obj c parser is not used)

Can you help me out with the tinyXml implementation.
Thanks.

Hi Zohaib,

I’ve attached a rar with some classes that I used for loading plist files using tinyxml. I hope they’re useful.

Isaac

Hey Isaac,
Thanks.
I’ll have a look at it and let you know :slight_smile:

Hey Isaac,
There’s a file included in the project PortTypesdef.h.
What does it contain. Because I’m getting errors in the file ENSDictionary.h

It just contains some defines that convert the NS* classes to CC* classes, for help with porting. Just replace references from things like NSObject to CCObject and you should be able to remove the #include for that file and get it to compile. But I’d recommend just looking through the code that uses the TiXml* classes to see how they work, and integrate it into your own solution.

Hey,
Thanks.
Yeah I figured that out after posting.

I was just integrating it with my problem just to easily follow it.
Thanks for the help :slight_smile: