|
@@ -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();
|
|
|
}
|
|
|
},
|
|
|
|