Need to create C++ game for Android.

Hi all,

I want to develop a game in C*+ for Android. I learned about cocos2d-x and wish to use this engine. I took tutorial that describes how to create and build project using cocos2d-x. I know c**.

  1. Need to know most general constructs provided by cocos2d-x for game development that are useful. Which libraries will be helpful most?

  2. Can i get tutorial for game development in C*+ for/with cocos2d-x that will be deployed on android(or related to this). I googled it but could not find satisfactory tutorials. Please suggest.

  3. Are there any restrictions for C*+ while using with cocos2d-x. I mean to ask, does any syntactically and semantically code in C*+ work with cocos2d-x? Are there any restrictions?

Appreciate your help.

  1. Cocos2d-x is almost the same to cocos2d-iphone when you ignore the multi-platform layer. At the game development view, you can read the book Learn iPhone and iPad Cocos2D Game Development or Cocos2d for iPhone 0.99 Beginner’s Guide as the first step.
  2. [[Tutorials]] on the wiki is a good example, and the zip ball of Cocos2dxSimpleGame is in download.cocos2d-x.org
  3. STL & template is OK. Make sure the NDK version is higher than r5 before you use RTTI. Boost isn’t supported.

Hey thanks for quick answer, Walzer.

I have ndk r6.

I guess, android game development is same as that for iphone except multi-platform layer.
However i don’t have any prior game development experience in iphone. Will post questions related to it here on the forum.

Actually i need to develop a snake game(like [[kryshen.net/games/bmtron.html]]) in C++ for android. I decided to use cocos2d-x for the same.
Will post questions related to it. Please share something that might help.:wink:

Thanks again.

You’re always welcome. Please feel free to ask questions on the forum.
And you can find a 2dx snake game here http://www.cocos2d-x.org/projects/cocos2d-x/apps/57

I am following the [[http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Chapter_2*-*How_to_Add_a_sprite]] tutorial. It’s very good. I successfully modified the HelloWorldScene file then built using build_native.sh script. It successfully built.

Then I tried to import the built project on android so that i can mount it on avd. but it showed some error with `Override for 3 files.

Cocos2dSimpleGameForAndroid.java (main activity file)
Cocos2dxAccelerometer.java (org.cocos2dx.lib package)
Cocos2dxGLSurfaceView.java (org.cocos2dx.lib package)

The error was same for all the three files i.e. “The method afterTextChanged(Editable) of type TextInputWraper must override a superclass method”

I see the error is simple java error saying that it must implement the superclass abstract method.
Then i removed `Override annotation above the method implementation. It worked fine.

The same thing happened with other project too.

My concern was, is it routine practice to remove @Override annotation? Is it some bug? or I am making some silly mistakes.

Thanks.

Because some interface used by cocos2d-x adds some methods on highter version of Android sdk,
so you should implements them.

Just implement them and return a default value(int with 0, boolean with false and so on).

Devang Shah wrote:

I see the error is simple java error saying that it must implement the superclass abstract method.
Then i removed `Override annotation above the method implementation. It worked fine.

The same thing happened with other project too.

My concern was, is it routine practice to remove `Override annotation? Is it some bug? or I am making some silly mistakes.

check the “Java Compiler” settings in the project’s Properties

set the “Compiler compliance level” from 1.5 to 1.6

maybe it’s a bug in jdk 1.5