Do i can use java methode in cocos2d-x?

Hi everybody
i want create multiplayer game and i want use socket programming in java language with c++ in cocs2d-x
Do i can use java method in cocos2d-x?

take a look in cocos2d\cocos\platform\android\jni files.

1 Like

I wouldn’t necessarily suggest using JNI for socket networking, but it is possible.

You will use JNI (Java Native Interface) to call Java code from C++ and to call C++ code from Java.

Here is a good technical overview of JNI

And as @hzlov said, cocos2dx\cocos\platform\android\jni is a good place to look for examples.

1 Like

The question is, why do you want to do that?
Just do socket programming in C++ without any Java drag.

1 Like

how i do socket programming in cocos2d-x by c++ or JavaScript?
i want to create a multiplayer offline game by hotspot

Why do you need socket programming for a multiplayer offline game?
What do you mean “by hotspot”?

If you meant multiplayer online game:

Use the network functionality of cocos2d-x:
http://www.cocos2d-x.org/reference/native-cpp/V3.3rc0/d6/d7c/namespacecocos2d_1_1network.html

or use a third party lib like RakNet:
http://www.jenkinssoftware.com/ https://github.com/OculusVR/RakNet

or use the C++ lib of Google Play Game Services:

@iQD
By hotspot he means that connecting turning wifi og one device and connecting several devices to it and they all are not connected to internet I mean the exchane of data is not taking place via internet but just wifi… :stuck_out_tongue:

1 Like

I want create multiplayer game like Blobby Volley , so i want connect two or more device to each other over wifi
in first step one of players create hotspot and in the next step other players connect to him/her hotspot therefore they connect to each other in a local network
this method is using in different apps like ZAPYA
how can i do that in different language like C++ or JS ?
thanks for your answers

Ah, thanks. I was puzzled by the term “offline”, as wifi and “hotspotting” is still online :smile:

So basically the request was about WLAN multiplayer.

With the info/code linked in my previous post.