1. TnkAd SDK‎ > ‎

6) Cocos2dx Settings

Download cocos2dx plugin file here. [Download Cocos2dx plugin]

Unzip the plugin file and you can see the files as follows.

  • Classes : Plugin cpp file used in Cocos2dx. Copy to the Classes folder of your Cocos2dx project.
  • proj.android : plugin file for Android and TnkAd SDK itself. Copy into libs folder of Android project.
  • proj.ios : Plugin file for iOS and TnkAd SDK library itself. Copy to Xcode project.

[Android Settings]

Do android settings first. See 3) Android Settings for details.
Then follow steps below.
  • tnkadcocos2dx.jar is plugin file for Android. Copy into libs folder of Android project
  • TnkAdPlugin.cpp and TnkAdPlugin.h file is plugin cpp file used in Cocos2dx. Copy both files to Classes folder of Cocos2dx project.
  • Open jni/Android.mk file and add a line as below in order to NDK builder complie the plugin cpp files together.
 [Edit proj.android/jni/Android.mk file]

  • Open main Activity java file in Android project and add a line in onCreate() method as follows.

Initialization of plugin

public class spaceship extends Cocos2dxActivity {

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);


        //TnkSession.enableLogging(true);

        TnkAdCocos2dxPlugin.setCurrentActivity(this);

    }


    // ...    

}


[iOS Settings]

Do iOS settings first. see 4) iOS Settings for details.
Then follow steps below.
  • Add TnkAdPlugin.h and TnkAdPlugin.cpp files in Xcode project.
  • Add TnkAdCocos2dxBridge.h and TnkAdCocos2dxBridge.mm files in Xcode project.
Comments