4
\$\begingroup\$

Disclaimer: my goal is not to use cross-platform frameworks like Unity.

I am currently planning a mobile game which I intend to first launch on iOS. However, I am wondering if it is better to write everything in Objective-C, thus locking the code into the platform, and to do a complete rewrite for other platforms (ie: Android). The other option would be to write the game logic in C or C++ and to only write the code that interfaces with each OS in the preferred language (Objective-C(++) or Java).

I understand that this must depend on the size of the code base, so what program size should mark the separation? Finally, if I write cross-platform code, should I stick to C (since Objective-C is a superset of C, making it easy to use C and to use the code samples and because the NDK and the JNI interfaces are more C oriented)? The only advantage I see with C++ in that case is the fact that it is object-oriented and thus it is easier to represent game entities).

\$\endgroup\$
3
  • \$\begingroup\$ Unity basic license for Android and iOS is free for a few weeks.. I realize you seem to be against it (assuming cost) but once you write a few apps for a specific platform, you may change your mind. \$\endgroup\$
    – Chuck D
    Commented Mar 12, 2012 at 3:26
  • 2
    \$\begingroup\$ @RubberMallet There are tons of reasons not to use Unity, "assuming cost" is a wild and likely wrong assumption. \$\endgroup\$
    – o0'.
    Commented Mar 13, 2012 at 13:55
  • \$\begingroup\$ Stating that there are 'tons of reasons' for or against any platform sounds a bit fanatical. I would be interested in knowing what you are thinking of specifically. Any platform is strengths and weaknesses but not everyone has thousands of dollars for pro licenses and such. Unity is a good platform for certain games but obviously it's not for everyone, I realize this but it may be worthwhile unless you want to handle significant plumbing on your own... \$\endgroup\$
    – Chuck D
    Commented Mar 13, 2012 at 18:05

6 Answers 6

6
\$\begingroup\$

The "worth" of something can only be determined by you. For some people it isn't worth porting to android for the amount of time spent vs. sales.

That being said there's no reason to just use C++ for everything. Sure, the interfaces for certain things is C or Objective-C, but you can call both of those easily from C++.

\$\endgroup\$
1
  • \$\begingroup\$ To counter the argument at the end of the linked article, I have talked to a handful of mobile developers that all share the same rhetoric, if you are looking to make an income from mobile development you should target iOS. The Android market has proven itself to not be as willing to pay for what the iOS market will. \$\endgroup\$
    – James
    Commented Mar 11, 2012 at 19:54
2
\$\begingroup\$

I'm into XNA for Xbox360 development, and some of the developers that have written games for Xbox and PC in C# reported that porting to C++ and other platforms wasn't very hard at all.

Full portability is probably not a good idea, as the UI should be tied to the platform. This means you'll probably need to design specific UIs for iPad, iPhone and various Android devices.

The game logic on the other hand, can be written in such a way that it does not reference the OS directly, allowing to share the code among platforms, or at least make it painless to port between languages and platforms.

Finally, it's worth mentioning .net and C#, which are available on PC, Xbox 360, iPhone/iPad (mono touch), Android (mono for android), Windows Phone 7 and PlayStation Vita. That's quite a wide range of platforms.

\$\endgroup\$
1
\$\begingroup\$

You could rewrite everything for both platforms, but that would take a lot of time. Another option is, like you suggested, to write the OS dependent code in Objective-C and Java and then write the core of the app in C. If it is a little app, then the first option shouldn't be too much of a hassle, especially if you're just embedding a web page or something similar. But for larger apps (ex. 3d multiplayer games) the second option is better. You said you didn't want to use a cross-platform framework like Unity, but if you went with the second option you'd essentially be writing your own library. If your game requires a lot of OS specific things than this could be difficult to implement as well. And there are some frameworks which do almost exactly what you said (implement OS specific stuff then let you use C or C++ to write code) like MoSync.

As for C vs C++, if you really like C++ and can't stand to code in C, then it's worth using C++, but otherwise I'd say stick with C because it could be very difficult to use C++, though I don't know for sure. I'd look into using C++ with the NDK.

\$\endgroup\$
1
\$\begingroup\$

While this falls in line with some of the other answers, I'll make this case: Cross-platform development can mean not only two different platforms at the same time, but also the same platform at two different times.

By that, I mean that every line of code that depends on a platform/OS specific feature is one that will have to be rewritten should the exposed functionality of the platform be changed at a later date. If you keep your codebase platform agnostic, you only have to worry about updating the OS abstraction layer to accommodate new changes.

\$\endgroup\$
0
\$\begingroup\$

It definitely depends on your audience. You should figure out first who they are and what platforms are used by them and in what proportion. When thinking over this issue it's worth deciding on the geographic region, since the findings might differ not only within user groups but also for different locations. Next, you must reflect on the priorities for product growth and the resources available. Start working on several platforms from scratch at once might lead to uncertain results Thus, it's worth prioritizing based on the audience research. After releasing your prototype on one platform, it might be easier and safer to invest in other relevant platforms.

\$\endgroup\$
-1
\$\begingroup\$

you definitely want to think cross platform. iOS may be most lucrative now but a lot of developers are now quietly moving to Android. if your game is successful, you will want to localize and release in other markets and, for example, Asia is more of an Android world.

There are platform independent toolkits, like Unity, so investigate those. You also have HTML5 as a possibility.

bottom line is this - if you are successful, you will want to go cross platform. If you are not, that could also be because you did not try all platforms. so better think cross platform right away :)

\$\endgroup\$
8
  • \$\begingroup\$ -1 This advice is just unsubstantiated assertions. There are no figures presented, there is no insight into why people might be moving to Android (maybe they are not even going cross-platform), and the answer never actually addresses why someone would want to do it. It just asserts: "Well, some people are doing it. If you are successful, you will want to do it." (okay, I hear you, but WHY?) \$\endgroup\$ Commented Mar 12, 2012 at 3:46
  • \$\begingroup\$ -1 he said, in the very first line, his goal was not to use frameworks like Unity... and you suggest just that. \$\endgroup\$
    – o0'.
    Commented Mar 12, 2012 at 8:19
  • \$\begingroup\$ @JonathanHobbs omg! what a way of welcoming someone new! "there are no figures presented" - ok, sorry, next time I will not answer till I have figures. "okay, I hear you, but WHY" read it again \$\endgroup\$
    – Greg Bala
    Commented Mar 13, 2012 at 13:41
  • \$\begingroup\$ @Lohoris sorry, i missed that \$\endgroup\$
    – Greg Bala
    Commented Mar 13, 2012 at 13:44
  • \$\begingroup\$ @GregBala Being new doesn't stop your answer being bad. Your answer is bad, so I have given it a -1. \$\endgroup\$ Commented Mar 13, 2012 at 14:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .