Creator

Clone URL of Demo

Creator Project:

git clone http://dnsdk.vimedia.cn:8080/r/CreatorDemo.git

Import Creator Plugin

Copy the 'assets/Wb' folder from CreatorDemo into your project to complete import.

The main interfaces include 'ADManger' , 'CoreManger', 'TjManger', 'ToolManger' etc.

Use interface

Import 'Define.ts' and then use interface:

import {Wb} from "../../Wb/Scripts/Define";

Wb.ADManager.Instance.openAd("home_mfzs");

Reference bellow:

1. Core Ability

1、 Open exit game(must)

Wb.Tool.applicationExit();

2、Get parameters of Application

let pname = Wb.Core.getPackageName();//get package name
let prjid = Wb.Core.getPrjid();//get project id
let imsi = Wb.Core.getImsi();//get imsi
let imei = Wb.Core.getImei();//get imei
let lsn = Wb.Core.getLsn();//get lsn
let appid = Wb.Core.getAppid();//get appid
let channel = Wb.Core.getChannel();//get channel
let vername = Wb.Core.getVerName();//get version of Application
let result = Wb.Core.getAuditSwitch();//Get custom switch value(Return: 0-not audit 1-auditing)
let state = Wb.Core.getNetState();//Obtain network status (0- No network 1- Mobile network 2- WiFi network 3- Ethernet network 4- Bluetooth network)
let result = Wb.Core.getCustomSwitch(inputValue);//Get custom switch value(Return: 0-not audit 1-auditing;inputValue:custom key name)

2. Advertising Ability

1、Open the general AD(interstitial/reward video/banner/splash)

Wb.Ad.openAd(adName: string, callback: Function);

2、Open the native AD(interstitial/reward video/banner/splash)

Wb.Ad.openYsAd(adName: string, width: number, height: number, x: number, y: number, callback: Function);

3、IS AD Ready

Wb.Ad.isAdReady(adName: string);

4、Close AD

Wb.Ad.closeAd(adName: string);

5、Get video limit open number

Wb.Ad.getVideoLimitOpenNum();

6、Is AD be opened in level

Wb.Ad.isAdBeOpenInLevel(adName: string, level: number);

7、Is AD type exist

Wb.Ad.isAdTypeExist(adName: string);

8、Get AD position param

Wb.Ad.getAdPositionParam(adName: string, param: string);

3. Analysis Ability

1、Custom statistics

Wb.Tj.tJCustomEvent(eventId: string);
Wb.Tj.tJCustomEventLabel(eventId: string, label: string);
Wb.Tj.tJCustomEventHashMap(eventId: string, attributes: string);

2、Checkpoint statistics

Wb.Tj.startLevel(level: string);
Wb.Tj.finishLevel(level: string, score: string);
Wb.Tj.failLevel(level: string, score: string);

3、Recharge statistics

Wb.Tj.tJPay(money: string, coin: string, source: number);
Wb.Tj.tJPayAndBuy(money: string, item: string, number: number, price: string, source: number);//充值并购买

4、Page statistics

Wb.Tj.onPageStart(sid: string);
Wb.Tj.onPageEnd(sid: string);

Android

1:Add maven repositories

   buildscript:

   buildscript {
    repositories {
        maven {
        //WB plugin
            url "http://dnsdk.vimedia.cn:8081/repository/vimedia-public/"
        }
    }
  }


  allprojects:

  allprojects {
    repositories {
        maven {
           //WB plugin
            url "http://dnsdk.vimedia.cn:8081/repository/vimedia-public/"
        }
        //ironsource plugin
        maven {url  "https://dl.bintray.com/ironsource-mobile/android-adapters/"}
        maven {url "https://dl.bintray.com/ironsource-mobile/android-sdk"}
    }
  }

2:Add in project gradle.properties

android.enableJetifier=true
android.useAndroidX=true

3:Implementation modules

    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'androidx.navigation:navigation-fragment:2.3.0'
    implementation 'androidx.navigation:navigation-ui:2.3.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.18'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.vimedia.core:common:1.2.1'
    implementation 'com.vimedia.core:kinetic:1.5.9'
    implementation 'com.vimedia.core:plugin:1.1.1'
    implementation 'com.vimedia.ad:manager:1.4.5'
    implementation 'com.vimedia.ad:ironsource_JuHe:1.0.2'
    implementation 'com.vimedia.tj:manager:1.0.5'
    implementation 'com.vimedia.track:manager:1.0.7'
    implementation 'com.vimedia.pay:manager:1.0.8'
    implementation 'com.vimedia.game:manager:1.3.6'

4:Add proguard config

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources false
            // here added 'vigame_proguard.pro'
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'vigame_proguard.pro'  
            signingConfig signingConfigs.release
            zipAlignEnabled true
        }
    }

If the release version does not enable minify, you can skip

5.Add Creator module in build.gradle

   implementation 'com.vimedia.game:creator:1.0.4-2'

6.Modify Application.java

Add code in the corresponding life cycle in MyApplication class:

public class MyApplication extends Application {
    /**
     * onCreate lifecycle.
     */
    @Override
    public void onCreate() {
        super.onCreate();
        DNSDK.applicationOnCreate(this);
    }

    /**
     * onLowMemory lifecycle.
     */
    @Override
    public void onLowMemory() {
        super.onLowMemory();
    }

    /**
     * attachBaseContext lifecycle.
     */
    @Override
    protected void attachBaseContext(final Context base) {
        super.attachBaseContext(base);
        DNSDK.applicationAttachBaseContext(this, base);
    }

}

Or

Made your MyApplication class inherit DNApplication:

public class MyApplication extends DNApplication {

}

7.Modify AndroidManifest.xml

Add related parameter configuration, And use VigameStartActivity as launch item.

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.cocos2d.demo"
    android:installLocation="auto">

    <uses-feature android:glEsVersion="0x00020000" />

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

    <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:name="org.cocos2dx.javascript.MyApplication"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher">

        <!-- Parameter begin -->
        <meta-data
            android:name="com.vigame.sdk.appid"
            android:value="${DN_APPID}" />
        <meta-data
            android:name="com.vigame.sdk.appkey"
            android:value="${DN_APPKEY}" /> 
            <!-- Parameter end -->
        <meta-data
            android:name="com.vigame.sdk.prjid"
            android:value="${DN_PRJID}" />
        <meta-data
            android:name="com.vigame.sdk.channel"
            android:value="${DN_CHANNEL}" />

        <!-- Tell Cocos2dxActivity the name of our .so -->
        <meta-data android:name="android.app.lib_name"
                   android:value="cocos2djs" />

        <activity
            android:name="com.vimedia.game.VigameStartActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/AppWelcome"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="org.cocos2dx.javascript.AppActivity"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:launchMode="singleTask"
            android:taskAffinity="" >
        </activity>
    </application>

</manifest>

8.Made the main Acitivy inherit CreatorWbActivity Or Made the CreatorWbActivity as main Activity

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import com.vimedia.ad.common.ADContainer;
import com.vimedia.creatorbridge.CreatorWbActivity;

public class AppActivity extends CreatorWbActivity implements ADContainer {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public Activity getActivity() {
        return this;
    }

    @Override
    public void addADView(View view, String type) {
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
        this.addContentView(view, params);
    }

}

CreatorWbActivity has inherited Cocos2dxActivity

9.Put in the configuration file and modify

Copy VigameConfig.xml to assets dictionary.

And You can configurate ConfigVigame.xml in assets. Property description is as follows:

10.Configuration items of test

1).Open app/build.gradle,modify package/channel/umeng appkey.

Recommendation the package name as follows for Advertising display

defaultConfig {
            manifestPlaceholders = [
                DN_CHANNEL      : "google",
                DN_APPID        : "37683",
                DN_APPKEY       : "wfm542g5dc40n0qmynbtxhthj2kdnhcm7gc99fs1ts8jloayyz",
                DN_PRJID        : "3361",
                UMENG_APPKEY    : "591e8a3275ca3549e8000e5c",
                GDTAppId        : "",
                GDTAppKey       : "",
                KuaiShou_Appname: "",
                HEADLINE_APPID  : "",
                KuaiShou_Appname: "",
                HEADLINE_APPID  : "",
                KuaiShou_Appid  : "",
                ReYunAppKey     : "",
                ADMOB_APP_ID: "ca-app-pub-7851203648968517~5682113463"
        ]
}

2).Modify the background of Splash AD.

If needs,repalace "bg_splash_vigame.png" file in res/drawable.

最后更新于