Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

As an Android game developer, what should I keep in mind while developing my game if I ever wanted to cross-platform the game to the iPhone? Any strategies, tips, etc. on porting to both of these mobile platforms?

share|improve this question
    
What language is most of your code written in? Java? C/C++? –  Jason Kozak Jul 20 '10 at 0:34
    
Android (and my app) is written in Java. iPhone is Objective C –  Bryan Denny Jul 20 '10 at 12:33
add comment

4 Answers

up vote 11 down vote accepted

Write it in C/C++ -- this is the biggest thing you can do. Both platforms support C and C++, though in different ways. On Android, you'll be using the NDK. On the iPhone, it can be compiled along with the Objective-C code.

You'll need to invest some time building the scaffolding around your C/C++ code for each platform. You should be able to be fairly generic in this area, since it's really just connecting up the OS specific functionality into your game code. Don't skimp in this area unless you're only planning to do one cross-platform project or that you don't mind re-inventing the wheel for every project you do.

Use OpenGL ES -- both platforms have OpenGL ES support. Take advantage of it. This will minimize the amount of code that you need to re-write. You will still have some differences on each platform, but overall most of your code will work on both.

Avoid platform/language specific APIs -- this should go without saying, but it's easy to be sucked into using the Java collection classes while you are working in Java. Of course, if you followed the first rule above, you won't be doing much in Java. Same goes from the opposite way -- as nice as the Foundation classes are in iOS, if you want to port to another platform, avoid them.

As you can see, there is a lot of things to worry about by going cross-platform. If you are a small indie developer, it may not even be worth your time. You will have to evaluate if you really want to blaze your own trail so that you can target multiple platforms. It may be worth taking advantage of what each platform has to offer in order to have a faster development cycle.

Good Luck!

share|improve this answer
1  
Could you elaborate on what you mean by scaffolding around the c++ code. If possible could you link a tutorial showing what it would entail as I don't really understand what you are getting at. –  Skeith Apr 5 '12 at 12:02
add comment

That will be a largely painful process going from Java > Objective-C.

Data Driven
Build a game that is largely data driven. I think this speaks for itself, but this direction leads to less work you must completely re-implement.

High and Tight
Keep things very small and modularized. I say this because it will be much easier to port if you can easily take a component and implement just it, test and repeat.

Contract Work
Play your cards right and you might know someone who can take care of this for you. If you're best friends with an iPhone developer you might be able to buy him/her some dr. pepper to help migrate your code over.

Use a Multi-Platform Engine
If you've got a project in motion already then it doesn't make much sense. But if you're about to do a project, that you absolutely know will be ported to other platforms, then it might be worthwhile to take advantage of existing technology to help put your world together. Unity3D will be getting Android support with Unity 3.0.

Conversion /shudder/ Tool
And my least favorite recommendation is that you could use some sort of conversion tool to at least get your models converted from Java > C... But... I don't endorse that.

share|improve this answer
add comment

If you're thinking of porting to the iPhone and your game is still in development, then switch to C++ if you haven't already. It will make your code significantly more portable when the time comes.

share|improve this answer
add comment

Going to add my two cents to this thread - consider writing your game in a cross platform language like many of the others have said here... but consider C#! It's a powerful language that is managed and provides a lot of great features that C++ doesn't that can assist in game development - and a great library known as MonoGame exists for it which is akin to XNA which runs on all sorts of platforms. As of Version 3.0, at the time of this writing, it's possible to write full fledged games and port to all mobile platforms with ease.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.