Need help getting started with Cocos2d-x to build for iOS & android

Just my 2c regarding the answers from @pococogames

As I understand, he wants to use some platform specific features.

Well, I already answered that question.

This is an option, not a requirement.

Use a cross-platform language like Swift or Haxe instead.

yep, haxe is good idea. But I donā€™t know, is there any cocos2d port for haxe?

As I know, there is no Haxe port and I can imagine there never will be. It would be a lot of work to support all backends.
cocos2d-x is just a cpp framework, so it would target only the Haxe cpp backend anyway.

If you donā€™t want to use cocos2d-x tho, there exist plenty of awesome Haxe game frameworks.

Yep I had heard Haxeflixel. Did you use haxe? I just wonder, what do you think about cross compiler side of haxe? is it perfect?

I benchmarked and tested the major frameworks including HaxeFlixel. HaxeFlixel has not the best performance, but plenty of cool features.

Yes, Iā€™m using Haxe with Kha and various other Haxe libs.

Itā€™s just awesome. The language features are really great and the performance, depending on the framework, is outstanding. Despite using a GC, itā€™s nearly on par with C/C++ code. There never will be the perfect solution, but using a Haxe framework comes really close to that.
One codebase reaches Windows, Mac, Linux, iOS, Android, Windows Phone, HTML5, Flash, Raspberry Pi, Xbox One, Tizen, PS Vita, PS4 and even Unity 3D (there are even more backends in the working).
The supported backends are also depending on the framework used.

Look at some benchmarks:
http://themozokteam.com/playground/frameworkstest/

cocos2d-x is below LibGDX (around MonoGame), as it heavily relies on a scene graph, which is hammering on the performance. The other frameworks do no rely on a scene graph.

E.g. my bunnymark on a Samsung Galaxy A5 (2016):
cocos2d-x: 2000 bunnies @ 60fps
Kha: 9000 bunnies @ 60fps

Real world results are depending on various other parameters and every engine/framework supports different features and have different usages and implementations.

Hey thanks to detailed reply. Haxeflixel developers really love their development environment. I will try it in the future.

Did you try in ios platform? I heard cocos2d-x performance isnā€™t better in android than ios. I had heard kha performance. I carried out a benchmark between unity and cocos2d-x with iphone4s.

if you have iphone4s device, may you try benchmark with kha and share results to me?

proj.android-studio created when I create project with source code, and without proj.android-studio when using libs. Thats a bug?

So, lets pick an example - I created project with pre-compiled libs and now I want to add simple 1 in-app for android. How can I do that?

As I said before in previous my post, I donā€™t know it this needed, just asking.[quote=ā€œpococogames, post:50, topic:33909ā€]
You already use NDK to build c++ project to android platform. I developed an android game with cocos2d-x and I never use java until today.
[/quote]

Thats interesting. And I donā€™t want to use sdkbox or any other, I just want to implement my open source code.

Yes, I would need to load and show game center score to user in android. Or this possible using only C++ code?

Youā€™r welcome.

Yeah, itā€™s cool.
The problem with HaxeFlixel is itā€™s performance. It does not come close to other solutions.
Another thing you have to consider is itā€™s Flash API. Maybe you donā€™t like that.

Not at the moment. But look at the benchmark from @nivrig. I added the link in my previous post. He was running the bunnymark on iPhone 6s.

Yeah, but the difference is minimal. The performance gaps between cocos2d-x and other frameworks is really the same on every platform, be it iOS, Android or Desktop. Itā€™s mainly because of the scene graph and differences in the backends. E.g. Kha and other frameworks even support Metal and Vulkan.

Plans are to beat Orx :wink:

Unfortunately I only have a non jail broken iPhone 4 at the moment. I will ask around if some one did a benchmark on various devices.

Could be a bug. Normally you have to use the --android-studio option to generate an AS project. Without that option, it will generate an Eclipse project.

With the IAP solution of your choice. SDKBox, MaaS solutions, IAP frameworks in C++ or with REST API.

Itā€™s only needed, if your framework you want to use is Java only.

SDKBox is a framework for various ā€œpluginsā€ like IAP. They basically wrap some other Open Source frameworks.

No. Game Center is an Apple exclusive framework. You have to use an alternative.
IIRC you are not even allowed to use their REST API on other platforms.

Sorry, I just call it currently like that I donā€™t know how itā€™s in android, but I know there is something same, where I can store leaderboards and scores. So I just want to implement it in my game.[quote=ā€œiQD, post:59, topic:33909ā€]
Normally you have to use the --android-studio option to generate an AS project. Without that option, it will generate an Eclipse project.
[/quote]

Can you please give an example? Because I donā€™t see how I can do this:

The Android equivalent to Game Center would be Google Play Games:
https://developers.google.com/games/services/downloads/sdks

Sorry for the misunderstanding. The option is only for cocos compile, so you can specify which build system to use.

cocos new should create all eight project folders for you by default.

The versions Iā€™m currently using:
cocos2d-x-3.12
Cocos Console 2.1

Which version do you have? Can you create a new project and check, which project folders are created?

Latest. And I have a lot of problems already as its really buggy and almost nothing just compiles and work. Info here - Prebuilt generation not working in 3.13.1 and 3.11.1 - #32 by anon98020523 :slight_smile:

Sure, Iā€™m doing this many times already.

Pleas post the commands you entered in both cases.

Ah, sure :slight_smile: :

1st

cocos new UseLibs -p projectname.com.name -l cpp -t binary

and 2nd

cocos new UseFullSourceCode -p projectname.com.name -l cpp

Firstly you canā€™t use game center on android platform. You may use google play service.

Sorry.I just had read your last post.

You always need to use official native plugin to add some services. SDKBOX Game Center solution(or smilar solutions) is just wrapper of official Game Center plugin. But ok, I understood you.

@iQD Thanks. Actually my mainly language option is c++ for game development. But I will try it for my future project. @slackmoehrle the discussion ended right now, sorry :smiley:

It seems that the binary templates is not supporting every build system yet.

You mean Android Studio and Eclipse? I donā€™t know, but libs canā€™t be used in Android studio or smth?

I was only referring to Android Studio, as there is a binary template for Eclipse but not for the former.
Every build system needs special configuration files for using prebuild libraries. Maybe these files are not ready yet for Android Studio.

Itā€™s the only reason I could imagine, why there is no binary template for Android Studio.

Iā€™m sure @slackmoehrle can answer that question.

I believe the Android Studio build is NOT fully working just yet.

@stevetranby Itā€™s a bit problematic to setup, but IT IS WORKING. I can confirm that :slight_smile: Now Iā€™m struggling to use precompiled libs to decrease compilation time, which is pretty slow on my iMac with goddamn 5400mbr hard drive. Feel free to help me fighting with gradle and ndk-build.

1 Like