How to port a simple project to win32,iPhone and Android

Discussion in 'Public Game Developers Forum' started by SuperSuRaccoon, Aug 11, 2011.

  1. I finished the installation and set up for the cocos2d-x(iphone-android) under Mac OS yesterday,
    here's the article:

    http://www.supersuraccoon-cocos2d.com/2011/08/10/cocos2d-x-iphone-androidide-installation-and-setup-under-mac-os/

    so I tried to port a very simple cocos2d-x win32 project I wrote several month ago to iPhone, android platform and win32 of course. The origin demo was here;

    http://www.supersuraccoon-cocos2d.com/2011/04/25/cocos2d-x-win32-installdeploy-tutorial/

    Here goes the whole process:

    1.Create a new project(Xcode) named SimplePortDemo under Mac OS using cocos2d-x-iPhone and make a little bit change of the origin code
    2.Create a new project named SimplePortDemo under Mac OS using cocos2d-x-android and then merge it into the iPhone project
    3.Create a new project(VS2010) named SimplePortDemo under WinXP using cocos2d-x-win32

    Here is the process in detail:

    1.Create a project for iPhone and android under Mac OS

    1.1 Create a new project named SimplePortDemo in Xcode

    1.2 Create a new project named SimplePortDemo using the shell script in cocos2d-x-android

    1.3 Copy the Android folder under SimplePortDemo to the following position:


    1.4 Edit the config file (according to yesterday's article)

    1.5 Rename the "AppDelegate" file (a bug)

    1.6 Complie && Run in Xcode and Success!

    1.7 Input the project in to Eclipse

    1.8 Complie && Run in Xcode and Success!

    2. Port the origin project to iPhone

    2.1 Copy the HelloWorldScene, MenuScene file into Xcode

    2.2 Change some of the codes:
    ※Some functions, macros, types that starts with NS, CG, UI such as NSSet, UIEvent, CGPoint, CGMakePoint need to be changed into something starts with CC :CCSet, CCEvent, CCPoint, CCMakePoint
    ※It's OK to use CCLOG here

    2.3 Complie && Run in Xcode and Success!

    3. Port the origin project to android

    3.1 No need to change any code here!The only thing you need to do is to edit the jni/helloworld/Android.mk file under android folder and add the MenuScene

    3.2 Run the build_native.sh

    3.3 Refresh the project in Eclipse, Complie && Run in Xcode and Success!


    4. Port the iPhone-android project (we just ported) to Win32

    4.1 Create a new project named SimplePortDemo in VS2010

    4.2 Add the HelloWorldScene, MenuScene we ported under Mac OS to the project

    4.3 Make a little bit of change
    ※ It's OK to use CCLOG but you need to cut off the "@" mark

    4.4 Complie && Run in Xcode and Success!

    Cheers! The whole port job is done now. As you can see from the whole process that you only need to make some small changes to the project to make it support win32, iPhone and android at the same time (at least it is so for a simple demo here) and that is pretty cool right :)

    PS: A litter bit of problems left here:

    1. The orientation of the project in the Android emulator since to be wrong (I don't have a real device so...)

    2. Before compiling the Android project, we need to add the MenuScene in the Android.mk manually. What if we have a lot of new files? Do we have to add it all manually?

    If you know the answer please let me know :) And if you have any questions about the whole process, feel free to ask and I'll try my best to answer'em .......

    SimplePortDemo_iPhone_android:
    http://dl.dropbox.com/u/30871449/Website/Resource/2011/08/SimplePortDemo/SimplePortDemo_iPhone_Android.zip

    SimplePortDemo_win32:
    http://dl.dropbox.com/u/30871449/Website/Resource/2011/08/SimplePortDemo/SimplePortDemo_Win32.zip

    PS: If you are interested you can check it here:
    http://www.supersuraccoon-cocos2d.com/2011/08/11/how-to-port-a-…ne-and-android/
     
  2. mehware

    mehware Well-Known Member

    Nov 22, 2008
    539
    1
    0
    or use Unity and its one click :D
     
  3. Yep, but it's not free :)
     
  4. mehware

    mehware Well-Known Member

    Nov 22, 2008
    539
    1
    0
    Time vs money I guess for ports. You can do a Mac app, win app or webplayer for free it does cost for android and iOS tho. Sorry for going off topic. Great initial post.
     

Share This Page