zh 8 miesięcy temu
rodzic
commit
e67aeb688e

+ 2 - 2
assets/Scene/scene.fire

@@ -14813,7 +14813,7 @@
       "__id__": 9
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 317
@@ -15171,7 +15171,7 @@
       "__id__": 9
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 325

+ 16 - 4
assets/Script/ATAndroidJS2.ts

@@ -4,10 +4,21 @@ const classJavaName = "org/cocos2dx/javascript/cocosjs/ATJSBridge";
 const classJavaParamName = "org/cocos2dx/javascript/AppActivity";
 const Cocos2dxHelper = "org/cocos2dx/lib/Cocos2dxHelper";
 
+/**
+ * 正式的
+ */
+const placementID="n1g03bq8qkeckn";
 
+/**
+ * 测试专用n6729e95f588aa    n66f7c61b71d4c
+ */
+const testPlacementID="n66f7c61b71d4c"; 
 
-const placementID="n1g0mbj573trfd";//正式的货柜
-const testPlacementID ="n66f7c61b71d4c";//测试用的AD
+
+/**
+ * 打砖块的
+ */
+const testPlacementIDForDzk="n67122e8932a3d";
 
 interface ATAndroidJS {
     getDeviceModel(): string;
@@ -169,8 +180,9 @@ const ATAndroidJS: ATAndroidJS = {
         return JSON.stringify(info);
     },
     getPlacementID:function(){
-     //   return placementID;
-     return testPlacementID;
+       // return placementID;
+        return testPlacementID;
+      // return testPlacementIDForDzk;
     },
     getDeviceUserId: function(){
         return this.getDeviceId()

+ 30 - 6
assets/Script/controller.js

@@ -9,10 +9,10 @@
  */
 
 
-// import   ATSDK  from "./AnyThinkAds/ATJSSDK";
-// import  ATRewardedVideoSDK  from "./AnyThinkAds/ATRewardedVideoJSSDK"; 
-// import   AAJS2  from "./ATAndroidJS2";
-// import AESUtil from "./AESUtil"
+import   ATSDK  from "./AnyThinkAds/ATJSSDK";
+import  ATRewardedVideoSDK  from "./AnyThinkAds/ATRewardedVideoJSSDK"; 
+import   AAJS2  from "./ATAndroidJS2";
+import AESUtil from "./AESUtil"
 
 cc.Class({
   extends: cc.Component,
@@ -33,7 +33,7 @@ cc.Class({
   },
 
   start() {
-    console.log('zh:00000000000000')
+    console.log('zh:controller 00000000000000')
     
     this.totalRank.active = false
     this.illustrative.active = false
@@ -43,10 +43,18 @@ cc.Class({
     }
     this.musicManager.init()
     this.lateStart()
-
+    this.initAdForPage()
     
   },
 
+  initAdForPage(){
+    console.log('zh:controller.js initAdForPage start')
+    let deviceId = AAJS2.getDeviceUserId();
+    console.log("zh:checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementID()));
+    var setting = {};
+    setting[ATRewardedVideoSDK.userIdKey] = deviceId;
+    ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementID(),setting);
+ },
 
   lateStart() {
     if (this.social.node.active) {
@@ -99,6 +107,22 @@ cc.Class({
     }
   },
   openPictorial() {
+
+     //ZH测试显示AD
+     if(2>1){
+      setTimeout(()=>{
+        if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementID())){
+            console.log('zh:AD  ready for controller.js')
+            ATRewardedVideoSDK.showAd(AAJS2.getPlacementID());
+        }else{
+            console.log('zh:AD not ready  for controller.js')
+        }
+       },300)
+    }
+ 
+
+
+    
     this.illustrative.active = true
   },
   closePictorial() {

+ 139 - 124
assets/Script/game.js

@@ -25,138 +25,153 @@ cc.Class({
     this.bindNode()
     this.generatePool()
     this.loadRes()
-    //this.initAd()
+    this.initAd()
 
   },
-    /**
-   * 广告初始化
-   */
-  initAd(){
-      console.log('zh:initAd 0')
-      let placementID = AAJS2.getPlacementID();
-      let deviceId = AAJS2.getDeviceUserId();
-      var setting = {};
-      setting[ATRewardedVideoSDK.userIdKey] = deviceId;
-      ATRewardedVideoSDK.loadRewardedVideo(placementID,setting);
-      //console.log('zh:bbb222')
-  
-      var customPlacementId = "";
-      if (cc.sys.os === cc.sys.OS_IOS) {   
-          customPlacementId =placementID;
-      } else if (cc.sys.os === cc.sys.OS_ANDROID) {
-          customPlacementId = placementID;
-      }
-       // 初始化SDK
-       ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试的AD
-       ATSDK.setLogDebug(true);
-       var GDPRLevel = ATSDK.getGDPRLevel();
-      var state = false;
-       const listener = {
-            onRewardedVideoAdLoaded(placementId) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
-           },
-       
-            onRewardedVideoAdFailed (placementId, errorInfo) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")");
-            //   BrickMsger.emit(BrickMsger.on_play_sound, 1);
-             //  BrickMsger.emit(BrickMsger.on_changeto_start);
-           },
-       
-            onRewardedVideoAdPlayStart (placementId, callbackInfo) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")");
-               let deviceId = AAJS2.getDeviceUserId();
-               var setting = {};
-               setting[ATRewardedVideoSDK.userIdKey] = deviceId;
-               ATRewardedVideoSDK.loadRewardedVideo(this.placementID,setting);
-           },
-       
-            onRewardedVideoAdPlayEnd (placementId, callbackInfo) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
-               //that.retrive();
-              //  BrickMsger.emit(BrickMsger.on_play_sound, 1);
-              //  BrickMsger.emit(BrickMsger.on_changeto_start);
-           },
-       
-            onRewardedVideoAdPlayFailed (placementId, errorInfo, callbackInfo) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
-             //  BrickMsger.emit(BrickMsger.on_play_sound, 1);
-            //   BrickMsger.emit(BrickMsger.on_changeto_start);
-           },
-       
-            onRewardedVideoAdClosed (placementId, callbackInfo) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdClosed(" + placementId + ", " + callbackInfo + ")");
-               console.log("onRewardxxxxxxclosed",state);
-               if(state==true){
-               //   BrickMsger.emit(BrickMsger.on_play_sound, 1);
-               //   BrickMsger.emit(BrickMsger.on_game_revie);
-                  state = false;
-               }else{
-                //  BrickMsger.emit(BrickMsger.on_play_sound, 1);
-                 // BrickMsger.emit(BrickMsger.on_changeto_start);
-                  state = false;
-               }
-           },
-       
-            onRewardedVideoAdPlayClicked (placementId, callbackInfo) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
-           },
+
+      //#region "AD  监听start"
+
+
+      onRewardedVideoAdLoaded(placementId) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
+    },
+
+     onRewardedVideoAdFailed (placementId, errorInfo) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")");
+     //   BrickMsger.emit(BrickMsger.on_play_sound, 1);
+      //  BrickMsger.emit(BrickMsger.on_changeto_start);
+       //测试AD  事件
+        // console.log('zh: ad over 开始发送事件aaaa')
+        // this.node.emit("handleCustomEvent");
+        // console.log('zh: ad over 开始发送事件bbb')
+
+
+    },
+
+     onRewardedVideoAdPlayStart (placementId, callbackInfo) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")");
+        let deviceId = AAJS2.getDeviceUserId();
+        var setting = {};
+        setting[ATRewardedVideoSDK.userIdKey] = deviceId;
+        ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementID(),setting);
+    },
+
+     onRewardedVideoAdPlayEnd (placementId, callbackInfo) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
+        //that.retrive();
+       //  BrickMsger.emit(BrickMsger.on_play_sound, 1);
+       //  BrickMsger.emit(BrickMsger.on_changeto_start);
+
+        // console.log('zh: ad over 开始发送事件1a')
+        // this.node.emit("handleCustomEvent");
+        // console.log('zh: ad over 开始发送事件OVER2a')
+
+
+    },
+
+     onRewardedVideoAdPlayFailed (placementId, errorInfo, callbackInfo) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
+      //  BrickMsger.emit(BrickMsger.on_play_sound, 1);
+     //   BrickMsger.emit(BrickMsger.on_changeto_start);
+    },
+
+     onRewardedVideoAdClosed (placementId, callbackInfo) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdClosed(" + placementId + ", " + callbackInfo + ")");
+        console.log("onRewardxxxxxxclosed",this.state);
+        console.log("zh:onRewardxxxxxxclosed",this.state);
+        if(this.state==true){
+        //    console.log('zh: ad over 开始发送事件1')
+        //    this.node.emit("handleCustomEvent");
+        //   console.log('zh: ad over 开始发送事件OVER2')
+
+          
+            // 发射自定义事件
+            // const eventData = new cc.Event.EventCustom('custom-event', false);
+            // eventData.detail = 'Hello from zhdiy!';
+            // this.node.emit('custom-event', eventData);
+            // console.log('zh: ad over 开始发送事件OVER33')
+
        
-            onReward (placementId, callbackInfo) {
-               ATSDK.printLog("AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")");
-               console.log("onRewardxxxxxx");
-               //BrickMsger.emit(BrickMsger.on_play_sound, 1);
-               //BrickMsger.emit(BrickMsger.on_game_revie);
-               state = true;
-               
-           }
-  
-       };
-       // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
-       ATSDK.getUserLocation(function (userLocation) {
-           //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
-           if (userLocation === ATSDK.kATUserLocationInEU) {
-               if(ATSDK.getGDPRLevel() === ATSDK.UNKNOWN) {
-                   ATSDK.showGDPRAuth();
-               }
-           }
-       });
-       ATRewardedVideoSDK.setAdListener(listener);        
-  
-       console.log('zh:initad 111')
-      // if (cc.sys.os === cc.sys.OS_ANDROID) {
-      //     console.log('zh:initad 222')
-      //     setTimeout(() => {
-      //         console.log('zh:initad 333')
-      //         var  allInfo = AAJS2.allInfo();
-      //         console.log('zh:initad allInfo'+allInfo)
-      //         ATSDK.printLog("zh:allInfo="+allInfo );
-      //         let key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
-      //         let iv = "Jn0.aWsOu$y-Dbqb";
-      //         let data = {data: AESUtil.AESencrypt(allInfo,key,iv)};
-      //         ATSDK.printLog("zh:allInfo-jm="+JSON.stringify(data) );
-      //         AAJS2.makePostRequestWithXhr(JSON.stringify(data));
-      //     }, 200);
-      // }
-      console.log('zh:initad 999')
-
-      //this.initAdForGameAd()
+            this.state = false;
+        }else{
+        
+          this.state = false;
+        }
+    },
 
+     onRewardedVideoAdPlayClicked (placementId, callbackInfo) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
+    },
 
+     onReward (placementId, callbackInfo) {
+        ATSDK.printLog("AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")");
+        console.log("onRewardxxxxxx");
+        //BrickMsger.emit(BrickMsger.on_play_sound, 1);
+        //BrickMsger.emit(BrickMsger.on_game_revie);
+        this.state = true;
+        
     },
+    //#endregion "AD  监听end"
+
+
     /**
-   * 广告AD
-   */
-  initAdForGameAd(){
-    setTimeout(() => {
-      let placementID= AAJS2.getPlacementID();
-      let deviceId = AAJS2.getDeviceUserId();
-      console.log("zh:checkstatus:",ATRewardedVideoSDK.checkAdStatus(placementID));
-      var setting = {};
-      setting[ATRewardedVideoSDK.userIdKey] = deviceId;
-      ATRewardedVideoSDK.loadRewardedVideo(placementID,setting);
-      console.log('zh:game ad init success')
-    }, 200);
+     * 初始化广告
+     */
+  initAd(){
+    console.log('zh:AD   init start')
+    let placementID = AAJS2.getPlacementID();
+    let deviceId = AAJS2.getDeviceUserId();
+    var setting = {};
+    setting[ATRewardedVideoSDK.userIdKey] = deviceId;
+    ATRewardedVideoSDK.loadRewardedVideo(placementID,setting);
+    //console.log('zh:bbb222')
+
+    var customPlacementId = "";
+    if (cc.sys.os === cc.sys.OS_IOS) {   
+        customPlacementId =placementID;
+    } else if (cc.sys.os === cc.sys.OS_ANDROID) {
+        customPlacementId = placementID;
+    }
+     // 初始化SDK
+     //ATSDK.initSDK("h67161678d3fcf", "aa0e53109399d0c3a213140e896bdac07");//正式的,发布提交go0gle play
+     //ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试专用,可以显示广告 ???      
+     ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是自己测试专用的
+
+
+     ATSDK.setLogDebug(true);
+     var GDPRLevel = ATSDK.getGDPRLevel();
+    var state = false;
+    //  const listener = {
+
+    //     //。。。。。。。。
+    //  };
+     // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
+     ATSDK.getUserLocation(function (userLocation) {
+         //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
+         if (userLocation === ATSDK.kATUserLocationInEU) {
+             if(ATSDK.getGDPRLevel() === ATSDK.UNKNOWN) {
+                 ATSDK.showGDPRAuth();
+             }
+         }
+     });
+     ATRewardedVideoSDK.setAdListener(this);        
+
+    if (cc.sys.os === cc.sys.OS_ANDROID) {
+        setTimeout(() => {
+            var  allInfo = AAJS2.allInfo();
+            ATSDK.printLog("zh:allInfo="+allInfo );
+            let key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
+            let iv = "Jn0.aWsOu$y-Dbqb";
+            let data = {data: AESUtil.AESencrypt(allInfo,key,iv)};
+            ATSDK.printLog("zh:allInfo-jm="+JSON.stringify(data) );
+            AAJS2.makePostRequestWithXhr(JSON.stringify(data));
+        }, 300);
+      }
+      console.log('zh:AD   init end')
   },
+
+
+
   
   loadRes() {