19

After using 'cocos2d-iphone' in one of my projects, I am trying to decide which flavor of Cocos2d I should use for an Android game. My personal list of pros and cons:

Cocos2d-x

pros: it should be easier to bring the game to iOS later, potentially other platforms as well

cons/doubts: debugging c++ code on Android (easy or not?), compatibility of NDK app with various Android devices (how much of a problem?), accessing platform-specific functionality (in-app purchases, etc.)

cocos2d-android

pros: all Java, easier to setup and access platform-specific functions

cons: will have to translate from Java to either c++ or Objective-C for other platforms

Are there other issues with either of the options that I didn't think about? If anybody had to make this choice, what did you choose and why?

Liya
  • 99
  • 6
Jason Weiss
  • 193
  • 1
  • 1
  • 5
  • 1
    FWIW, consider your familiarity with the language and tools, and pick that one. Your first goal is to finish your game on one platform. The consideration of a later port is relatively unimportant considering that most projects do not see the light of an App Store, and even when they do they are almost always not successful enough to warrant a port. – LearnCocos2D Dec 13 '11 at 11:31
  • Based on familiarity, I'd choose the Java version if I was sure it's stable enough. As far as not making money on iOS - been there done that :( Cocos2d-x really attracts me with it's portability promise. – Jason Weiss Dec 13 '11 at 19:12
  • of course choose cocos2d-x. it is more official now (go to cocos2d-iphone website and the latest – OMGPOP Dec 23 '12 at 14:27

4 Answers4

25

Note that there are two projects with almost the same name: cocos2d-android and cocos2d-android*1*. The latter is a fork of the former and its author did it because cocos2d-android project was almost dead.

In the beginning I was in doubt about cocos2d-android1 (which seems to be a very good work) and cocos2d-x but the possibility to develop in C++ (that I like a lot) and be multi-platform made me chose cocos2d-x.

I'm still trying to learn cocos2d-x.

What I like about it:

  • List item

  • it's a C++ framework

  • you can develop for Android, iPhone, Bada, Blackblerry Playbook, Windows and Linux. Please, notice that at the moment cocos2d-x team advises that Windows and Linux port are meant for easy your development not for production.

  • it has a Lua binding

  • it has a version for Marmalade (a paid multi-platform SDK)

cocos2d-x works with NDK since release 4. Currently I'm using NDK r7. You can develop for devices running since android 2.1 (API 7)

It seems that there are some issues with cocos2d-x on android 4 (what shouldn't be a problem because both it's still not that wide spread and cocos2d-x team will fix any problem they come across).

You will be able to access platform specific functionality like in-app purchase but it comes with a price: you will do almost everything using JNI.

Definitely it's harder than just putting a jar SDK into libs folder and directly call Java functions but it's feasible.

You can develop on Windows, Linux or Mac. For each OS you're using in the development machine the procedures to prepare your environment (cocos2d-x + target SDKs) varies. It's not a problem because you usually will stick with one of them.

Now let me tell you that it's not that easy to debug JNI / Java code. Why? Because there are many steps you must take to enable this and debugging process is slow.

So that cocos2d-x team advices to develop all your game for Linux or Windows and after that everything is up and running you compile it to Android. This way you will have minor problems to solve (if any)

I prefer to develop for android from the beginning.

All in all, I'm really happy coding with cocos2d-x. Community is very passionate about cocos2d-x and they are very supportive.

In the process of learning I wrote two tutorials:

Regards.

Plicatibu
  • 1,572
  • 2
  • 18
  • 20
  • These tutorials are helpful. But I am working in Windows 7. Are these tutorials work same in Windows 7? – AndroidDev Aug 04 '12 at 07:14
  • Unfortunately no. I failed to make it work on Windows + Cygwin. Sorry. – Plicatibu Aug 05 '12 at 23:01
  • do cocos2dx cocos2d-2.0-x-2.0.2 support in linux
    (ubuntu 11.10) for Android, i am facing below issue in module loading
    $(call import-module,CocosDenshion/android) $(call import-module,cocos2dx) $(call import-module,extensions)
    – Sameer Z. Oct 23 '12 at 07:34
  • Unfortunately I'm no using cocos2d-x since they started version 2.0, so I'm not able to help you. – Plicatibu Oct 24 '12 at 11:47
  • @MarcioAndreyOliveira are you still using cocos2d-x ? is it worth using.. ? – user739711 Jan 08 '13 at 04:14
5

I had the same problem 2 month ago. Cocos2d-Android is dead, so use cocos2d-x. Here some links and tutorials to start using it.

Community
  • 1
  • 1
vgonisanz
  • 11,352
  • 12
  • 74
  • 123
  • Every time I check a tutorial, its either asks to install each and everything compatible to COCOS or some says to add lines somewhere but doesn't specify where and why. No one is providing any reasonable tutorial for beginners. – Harpreet Mar 06 '13 at 10:43
  • If you doesn't like the official tutorials: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Step_by_Step_Cocos2dxSimpleGame_Series you can follow this book: http://cocos2dbook.com/book/ ; Its for objective-C but with small changes it is helpful – vgonisanz Mar 06 '13 at 10:49
2

If you are comfortable with C/C++ , by all means go the Cocos2d-x route. HOWEVER, if you are coming from an Android and Java background, with no experience in C++ , it can be a really painful experience getting everything in order. In asmuch as the Cocos2D for Android Project has been slow recently, I wont particularly say its dead. I used the version hosted on github here .. https://github.com/ZhouWeikuan/cocos2d

There are several tutorial on getting started.

Step by Step Guide on How to build your first Slider Puzzle game in Cocos2d for Android – Part 1 http://denvycom.com/blog/step-by-step-guide-on-how-to-build-your-first-slider-puzzle-game-in-cocos2d-for-android-part-1/

How To Make A Simple Android Game with Cocos2D http://dan.clarke.name/2011/04/how-to-make-a-simple-android-game-with-cocos2d/

For all others coming to this thread, I hope this is useful!

Vykthur D .
  • 331
  • 2
  • 7
0

cocos2d-x (98% in C++ and some Android Java Code) is the only version of cocos2d useful for Android.

cocos2d Android (all Java) may be useful if you want to create some prototypes, but as an active open source development project it is long dead and not maintained.

If you want to write a Java game on Android, use AndEngine - it is active and well maintained.

Jawa
  • 2,312
  • 6
  • 33
  • 36
Naligator
  • 156
  • 1
  • 1