Getting Started with Cocos2D

Hello!
-IRRELEVANT if you want to know the background
-RELEVANT to understand my questions

IRRELEVANT
(I was searching through the web, reading through the wiki and getting started pagw… Even watched some old youtube videos but I am still wondering how many things in cocos2d work.

I am coding apps for years now using the rather famous framework libGDX. Deploying to iOS is such a pain with it so it is time to move on for me. Also integrating iOS specific tasks isnt the smoothest thing either.

With the “latest” news from apple, they will deprecate OpenGL someday as you all know. Said framework is depending on OpenGL so I do not have any hope left.

The thing I like the most about libGDX was that you just needed to install it and then you could start coding and deploying (to desktop and android at least) in basically no time.)

RELEVANT

  1. I am coming from java, now using JS. Is it possible that I just install cocos2d, run it with IntelliJ and start coding in js without having to think about anything else?

  2. Cocos2D is build with C++, so that means it will use the NDK rather than the SDK right?
    Do I have to fiddle around with C++ at some point or will I be able to code my whole game using JS?

  3. I am running Windows mainly. How hard is it to deploy on iOS ? Do I just copy my project to my Mac and deploy it right away or how is it working? (I did not find any clear instructions)

  4. I like bare coding. Everything seems to be pointing at the Cocos Engine tho. Is there even a way to just code using JS without any GUI engine?

  5. What is happening in the background?
    IRRELEVANT
    (Speaking of libGDX: I am using java, it is compiled natively for android and using roboVM to translate it into “ios usable code”)

RELEVANT
The JS version is bound to the C++ backend I think? So the C++ backend will be compiled using the NDK for android and how will it be compiled for iOS and desktop?

  1. What about platform dependent code. How do I implement e.g. adding calendar events on android and iOS?

IRRELEVANT
(7. I came to this forum after around 2h of searching through the web. I searched here for any similar questions and I did not find any.
And to be honest, I did not look into posts from 2014 as I think that a lot might have changed in 3-4 years. - I did not find any satisfying answers (maybe I am just blind) - So I registered. After minutes I actually found the answer why I just cant open a new post right away). I have never seen such a (sry) stupid implementation of an user rank system. It reminds me of stackexchange, but there it isnt hurting that bad! - Maybe a developer could think about how to give this forum a game-like rank system without making newbies frustrated (or angry))

(I am from germany, my english is far from perfect and I am also typing on my smartphone. Sry!)

Thanks for you patience!

Use Cocos Creator if you want to write games in JavaScript. Cocos2d-js will be deprecated some day.

If you do deploy to Android you may have to add some ndk code depending upon what functionality you want to add. Btw we don’t have any built in calendaring functionality.

How do you do you know that is going to be deprecated, when and why?

It seems like that cocos2d js is not the way to go you would say?

I just know that Cocos Creator is where we put our JavaScript efforts. Creator is becoming an awesome tool. It can handle larger games too.

I’d say by Cocos2d-x 4.0 js will be deprecated.

Thanks for your answers!

I am now willing to learn C++, I think making a small game will let me memorize all the C++ stuff.

One last thing: Lets say I still wanted to write events to the android/apple calendar.

Is there a way to write that code in Java for android and XCode/obj c for iOS and include it in my project?

  1. Is it doable ?
  2. Is it doable without losing all my hair?

“I am running Windows mainly. How hard is it to deploy on iOS ? Do I just copy my project to my Mac and deploy it right away or how is it working? (I did not find any clear instructions)”

cocos2dx runs without any problems on android and ios if you only use the api cocos2dx gives you.
If you extend it you maybe have to edit it for the platform.

“Is there a way to write that code in Java for android and XCode/obj c for iOS and include it in my project?”
the implementation of the calendar is platform dependend.

obj-c: theres objc++ that can run your c++ code. to communicate with your c++ code you could create a shared header file and implement the functions in the objc++ part. (you need that because .cpp files cant include .mm (objc++) files but can include .h files)

java: you have to use JNI its simple. I used the cocos2dx simpleaudioengine src files to find out how jni works.

Seems doable. Thanks for your answer.

Last question for now:

Apple deprecated OpenGL for the future.

Will there be OFFICIAL metal or vulkan support in cocos2dx ?

I saw and read these 2 posts:


Does it actually mean that cocos2d will support metal officially without any breaking changes?

My fear is coding an app for month, then the new backend api will be relased and I am there with my game, that does not support the new backend.

Yes that is what it means. We will try hard for no breakage.

Nice to hear! I will give cocos2dx a try (or my c++ skills)

Many thanks to your replies!

C++ is my preferred language so if you have questions ask as long as they are related to Cocos2d-x somehow.

Hi @slackmoehrle,

When you say cocos2d-x JS will be deprecated do you mean cocos2d-x HTML5? Because I understand there are lots of differences in the web browser version and the JSB version (web version no longer gets the bug fixes and feature updates made for c++ and JSB version).

I don’t care a lot about the HTML5 version being deprecated, but it will be an issue if you stop supporting JS entirely in cocos2d-x using JSB.

1 Like