This document describes how to configure a Cocos2d project for the GME APIs for Cocos2d.
If you use Cocos Creator access, see Getting Started with Tencent Cloud GME.
Note:The SDK supports compilation on macOS.
GMESDK
folder must be added to the project).Add gmesdk.jar to the libs library.
Import the so
file into Activity
as shown below:
public class AppActivity extends Cocos2dxActivity {
static final String TAG = "AppActivity";
static OpensdkGameWrapper gameWrapper ;
static {
OpensdkGameWrapper.loadSdkLibrary();
}
}
Initialize in the oncreate
function exactly in the following sequence:
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);
super.onCreate(savedInstanceState);
//Initialize exactly in the following sequence
gameWrapper = new OpensdkGameWrapper(this);
runOnGLThread(new Runnable() {
@Override
public void run() {
gameWrapper.initOpensdk();
}
});
}
Configure your project for compilation options by referring to the Android.mk
in the GME Demo for Cocos.
preBuild.mk
file: /Users/username/Downloads/GMECocos/GMESDK/android/bin/preBuild.mk.Project configuration is required before you can export executables from the Cocos2d engine for different platforms:
Add the following permissions in the AndroidManifest.xml file of the project:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
If the voice messaging and speech-to-text feature is to be used, add the following under the application
node in the manifest file:
<application android:usesCleartextTraffic="true" >
Grant permission:
Allow Arbitrary Loads
permission as shown below:Please refer to SDK Download Guide to download Windows SDK and import it into the project.
Was this page helpful?