Why and when to use cocos2d?

Hello!
I was wondering if there is any reasons why to use cocos2d over something like swift and the xcode ui editor and when to use it, like would you also use cocos2d for creating quiz apps, food apps etc.?
Thanks!

what? I think you are asking when to use c++/js/lua vs swift?

I’d say you should use the one that you can learn the best. There is no correct choice. I can’t think of anything that Swift could do that c++ could not.

Cocos2D is best used for cross-platform 2D game development.

If you only care about releasing for iOS then definitely start with Swift/Xcode as it’s built specifically for apps and it has superior frameworks or 3rd party libraries like CocoaTouch UI, Networking (AlamoFire), Threading (GCD), and pretty much all other hardware/OS abstractions are better suited for apps. The build process will be simpler, etc. Again assuming you don’t care about other platforms.

C++ can do everything, but often at the cost of not being able to use the streamlined platform-specific frameworks and UI paradigms.

If you want to also support Android then you could look into using cocos2d-x, Xamarin, or a html/js/css toolchain.

2c

2 Likes

great answer Steve!

Thanks! But why is cocos2d best for 2d game development and not utility apps etc.?
I mean, I would also probably rather use the more standard xcode ios app template thing(not sure what it is actually called) where the UI is way easier to set up than in cocos2d and there are some pretty smart functions as you mentioned earlier…

this is a judgement call I think. For me i lean towards Cocos2d-x for a lot of things. i have been learning Unreal off and on sometimes. I like having the cross platform option for my games.

if i am writing an app and not a game i might use QT.

1 Like

Hmm okay then but why would you preferencer qt over cocos when making apps and not games? And why do you prefer cocos over other frameworks when making games?

You can make any software application (mobile/desktop) with almost any tool(chain), just like you could probably build an entire house with just a hammer. The “wrong” tool for the job might cause things to take much longer, however.

Cocos2d over Qt because it has many built in game features like Sprites (rendering custom textures), Animations (both frame-based and tweening), Input handling (more specific toward games, though it is touch based), and managing a run loop with low-latency high frame rate rendering and scheduling.

Qt is a great desktop UI framework if your app will be open source, otherwise I’m not sure how much a license to use it costs. Tiled (http://www.mapeditor.org/), for example, uses it. Again if you already know c++ then it’s a great choice. However, the mobile capabilities were not as great when I last tried about a year ago. YMMV.

Native Swift + iOS SDK using XCode and its Interface Builder, however, offers you easy usage of the Asset Catalog system (for multi-resolution), Auto Layout capabilities (for different Size Classes), easy use of platform features like Force Touch, Gyroscope, more direct and easier access to advanced Camera & Audio features should you need them. If your app is super simple than any framework will probably be fine, but if your target is iOS-only, seriously consider using the native language and platform.

Cocos2d has a UI library and a UI editor (Creator), but they’re both build for highly-customized usage because games usually want to design their own UI look and feel (interaction).

To give you even more choice (to paralyze you w/“Paradox of Choice”) you can write the cross-platform core business logic and networking stuff using c++ and even cocos2d, and then use the native UI libraries, frameworks, and tool chains for the surface visible layer of your app. This will be a bit more work, but even Xamarin (https://www.xamarin.com/), which is a c# cross-platform framework, effectively handles app creation in this manner by having you create 3 separate UIs and somewhat platform-specific UI logic.

While there’s a lot of merit to “use what you know”, sometimes that means you’re using a Hammer to try and screw in a lightbulb.

In the end it really matters more what your goal is here: learning, fun apps to share with friends, or to build a business off your apps either as a consultant building for others or as the seller of apps as a product.

Again my 2c only, and YMMV.

2 Likes

The one thing I’ll say, as I tend to do with anyone who asks this type of questions: Nail down your goals for the app/game design, pick a language, framework, and platform(s), and just get started. :smiley: It’s relatively easy to port fully-fleshed out ideas (compared to starting from scratch) to other languages, frameworks, and/or platform(s).

imho

2 Likes

Thanks, perfect answer!