Recently I’ve started my foray into the C++ world proper. I have always toyed a bit with the language and its predecessor C but I never really got into it fully, preferring instead languages such as C# and Haskell. However, due to the nature of the industry I work in, and due to how C and C++ make you think more about memory-efficient implementations, I thought it was high time I delved deeper into it. So far, personally I prefer the simpler C and languages such as C# and Haskell but hopefully this will change as I gather more knowledge about the language itself.
Just reading C++ tutorials and books is a bit boring though and learning is often more ‘fun’ when it is applied. Especially when it is applied to games! Hence, I’ve decided once again to try re-writing Space Generals. (Yes, yes, I’ve said this before). This time I opted for mobile and using the Cocos2dx engine.
Setting up Cocos2dx was not that hard but finding good up-to-date information online is hard since the engine is going through constant iterations. I am hoping the following set of steps help anyone who is looking to setup their Windows environment to be able to develop for Windows and for the Android platforms. They are very terse on purpose but should work. Let me know if you need more information and I’ll try dig it out for you.
Disclaimer 1: Cocos2d and Cocos2dx are in constant development so bear in mind that the information I have below might have already become outdated. Let me know and if I have some time I’ll update it accordingly.
Disclaimer 2: I work with a combination of Visual Studio 2013 and Eclipse Juno. If your target is simply Android, Eclipse should be enough. I assume you have some basic knowledge of how these two IDEs work. Having some knowledge of Android development would also be an asset.
Creating a Cocos2d-x project for Windows
Download and install
Creating the project
Creating a Cocos2d-x project for Android
The steps below assume the above section has been completed successfully.
Download and extract
Setup for deployment
Compiling and running the solution
Running and debugging
In Eclipse, assuming you have an Android virtual device setup, hitting run should make your game work using the default Cocos2dx-generated application. Unfortunately I had some problems with this due to a known issue related to my system configuration. Sometimes you cannot debug your application due to your graphics card not supporting a particular version of OpenGL which android supports. I am not a 100% sure why as I only did a quick Google search. There is help out there though if you encounter this problem. I hope you have more luck than me with this. If so feel free to comment.
In the end I resorted to coding and debugging my game in Visual Studio and then building it in Eclipse to create the apk which I then manually move to my Android device.
Hope that helps anyone trying their hand with Cocos2dx!