Преглед на файлове

Merge branch 'qqplay-1.0' of http://svn.ouj.com:3000/DWG/budingGame into qqplay-1.0

Roy преди 5 години
родител
ревизия
4746fd0514
променени са 3 файла, в които са добавени 86 реда и са изтрити 56 реда
  1. 61 54
      assets/Script/Game/GameSence.js
  2. 24 1
      assets/Script/Home/HomeSence.js
  3. 1 1
      assets/Script/UserInfoJS.js

+ 61 - 54
assets/Script/Game/GameSence.js

@@ -569,43 +569,54 @@ cc.Class({
     },
 
     onShieldBtn: function () {
-
-        if (CC_WECHATGAME && window.wx.createRewardedVideoAd) {
-            this.onPauseBtn();
-
+        if (CC_QQPLAY) {
+            this.onPassBtn();
+            
             var gameOverNode = this.node.getChildByName("GameOver");
             var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");
+            var isFinish = false;
 
             countDownLabel.stopAllActions();
+            
+            var videoAd = BK.Advertisement.createVideoAd();
 
-            let videoAd = wx.createRewardedVideoAd({
-                adUnitId: 'adunit-563ed529855c1195'
-            })
+            //加载成功
+            videoAd.onLoad(() => {
+                BK.Script.log(1,1,"videoAd onLoad")
+            });
 
-            videoAd.onClose(res => {
-                // 用户点击了【关闭广告】按钮
-                // 小于 2.1.0 的基础库版本,res 是一个 undefined
-                if (res && res.isEnded || res === undefined) {
-                    // 正常播放结束,可以下发游戏奖励
+            //开始播放
+            videoAd.onPlayStart(() => {
+                BK.Script.log(1,1,"videoAd onPlayStart")
+            });
+
+            //播放结束
+            videoAd.onPlayFinish(() => {
+                BK.Script.log(1,1,"videoAd onPlayFinish")
+                isFinish = true;
+            });
+
+            videoAd.onClose(() => {
+                if(isFinish) {
+                    // 看完15秒视频广告
+                    // 可以下发游戏奖励
                     this.getShield();
                     this.onPlayBtn();
                     cc.audioEngine.playMusic(this.gamebgMusic, true);
                 } else {
-                    // 播放中途退出,不下发游戏奖励
-                    this.onPlayBtn();
+                    // 未看完广告,不下发游戏奖励
+                    this.onPlayBtn()
                 }
             })
 
-            videoAd.onError(res => {
+            videoAd.onError(function (err) {
+                //加载失败
+                BK.Script.log(1,1,"videoAd onError code:"+err.code+" msg:"+err.msg);
+
                 this.onPlayBtn()
-            })
+            });
 
-            videoAd.load()
-                .then(() => videoAd.show())
-                .catch(err => {
-                    videoAd.load()
-                        .then(() => videoAd.show())
-                })
+            videoAd.show();
         } else {
             this.getShield()
         }
@@ -740,50 +751,46 @@ cc.Class({
         var gameOverNode = this.node.getChildByName("GameOver");
         var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");
 
-
-        if (CC_WECHATGAME && window.wx.createRewardedVideoAd) {
+        if (CC_QQPLAY) {
+            var isFinish = false;
             this.bShare = false;
             countDownLabel.stopAllActions();
+            var videoAd = BK.Advertisement.createVideoAd();
 
-            if (this.debugErrorTips) {
-                this.showWatchVdError();
-                return;
-            }
+            //加载成功
+            videoAd.onLoad(() => {
+                BK.Script.log(1,1,"videoAd onLoad")
+            });
 
-            let videoAd = wx.createRewardedVideoAd({
-                adUnitId: 'adunit-563ed529855c1195'
-            })
+            //开始播放
+            videoAd.onPlayStart(() => {
+                BK.Script.log(1,1,"videoAd onPlayStart")
+            });
+
+            //播放结束
+            videoAd.onPlayFinish(() => {
+                BK.Script.log(1,1,"videoAd onPlayFinish")
+                isFinish = true;
+            });
 
-            videoAd.onClose(res => {
-                // 用户点击了【关闭广告】按钮
-                // 小于 2.1.0 的基础库版本,res 是一个 undefined
-                if (res && res.isEnded || res === undefined) {
-                    // 正常播放结束,可以下发游戏奖励
+            videoAd.onClose(() => {
+                if(isFinish) {
+                    // 看完15秒视频广告
+                    // 可以下发游戏奖励
                     this.continueGame();
                     cc.audioEngine.playMusic(this.gamebgMusic, true);
                 } else {
-                    // 播放中途退出,不下发游戏奖励
-                    this.startFinishCount();
+                    // 未看完广告,不下发游戏奖励
+                    this.startFinishCount()
                 }
             })
 
-            videoAd.onError(res => {
-                wx.showToast({
-                    title: "拉取视频广告失败",
-                    icon: "none"
-                })
-
-
-            })
-
-            videoAd.load()
-                .then(() => videoAd.show())
-                .catch(err => {
-                    videoAd.load()
-                        .then(() => videoAd.show())
-                })
-        } else {
+            videoAd.onError(function (err) {
+                //加载失败
+                BK.Script.log(1,1,"videoAd onError code:"+err.code+" msg:"+err.msg);
+            });
 
+            videoAd.show();
         }
     },
 

+ 24 - 1
assets/Script/Home/HomeSence.js

@@ -46,7 +46,30 @@ cc.Class({
 		if(CC_QQPLAY && window.GameStatusInfo) {
 			GameStatusInfo.startMs = ((new Date()).getTime()).toString()
 		}
-		
+        
+        // let path = 'GameSandBox://qrcode2.png' 
+        // BK.QRCode.makeQRCodeToFileSync({
+        //     path: path,
+        //     content: 'hello world',
+        //     config: {
+        //         width: 256,
+        //         height: 256
+        //     }
+        // });
+        
+        // new BK.Game({
+        //     onShare: function(app) {
+        //         var shareInfo = {
+        //             summary: '分享正文',
+        //             localPicPath: path,
+        //             picUrl: 'https://pub.dwstatic.com/wxgame/budingGame/share/shareImage.jpg',
+        //             gameName: '游戏名称'
+        //         }
+
+        //         return shareInfo
+        //     }
+        // })
+
 		// if (CC_QQPLAY) {
 		// 	this.QQLogin();
 		// 	this.initShare();

+ 1 - 1
assets/Script/UserInfoJS.js

@@ -10,7 +10,7 @@ window.UserInfo = {
 	shareLimit : 3,		//分享次数限制
 	shareAddGold : 10,	//分享增加金币数
 	platform :  CC_WECHATGAME ? 1 : 0,		//1为微信小游戏模式
-	shareUrl : 'https://pub.dwstatic.com/wxgame/budingGame/share/shareImage.jpg',//分享图片地址
+	shareUrl : 'https://pub.dwstatic.com/wxgame/budingGame/share/shareImage2.jpg',//分享图片地址
 	shareDesc : '超级可爱的布丁,快来跟我一起玩吧',
 	shareDescChanllenge : '顽强的布丁',
 	wxversion : '6.6.3',