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

游戏结束我的分数同步

Roy преди 6 години
родител
ревизия
5e0234744f
променени са 3 файла, в които са добавени 21 реда и са изтрити 17 реда
  1. 2 1
      assets/Scene/GameSence.fire
  2. 3 2
      assets/Script/Game/GameOverRank.js
  3. 16 14
      assets/Script/Game/GameSence.js

+ 2 - 1
assets/Scene/GameSence.fire

@@ -8037,7 +8037,8 @@
       {
         "__id__": 199
       }
-    ]
+    ],
+    "myScore": -1
   },
   {
     "__type__": "cc.Node",

+ 3 - 2
assets/Script/Game/GameOverRank.js

@@ -93,8 +93,9 @@ cc.Class({
 
         if (this.myScore >= 0) {
             for (var i = 0; i < rankList.length; i++) {
-                if (rd.selfFlag) {
-                    rankList[i].score = this.myScore;
+                var rd = rankList[i];
+                if (rd.selfFlag && this.myScore > rd.score) {
+                    rd.score = this.myScore;
                 }
             }
             rankList.sort((a, b) => {

+ 16 - 14
assets/Script/Game/GameSence.js

@@ -191,10 +191,10 @@ cc.Class({
             }
             this.startFinishCount();
         } else {
-            gemeOverNode.getChildByName("OverBg").getComponent("GameOverRank").setMyScore(parseInt(UserInfo.getScore()));
+            gemeOverNode.getChildByName("OverBg").getComponent("GameOverRank").setMyScore(this.sumScore);
             gameOverNode.getChildByName("EndNode").active = true;
             gameOverNode.getChildByName("ShareNode").active = false;
-            
+
             this.gameOver();
 
             if (CC_QQPLAY) {
@@ -236,6 +236,8 @@ cc.Class({
 
     gameOver: function () {
         var gameOverNode = this.node.getChildByName("GameOver");
+        var overBg = gameOverNode.getChildByName("EndNode").getChildByName("OverBg").getComponent("GameOverRank");
+        overBg.setMyScore(this.sumScore);
         var historyScoreLabel = gameOverNode.getChildByName("EndNode").getChildByName("HistoryScoreLabel");
         var newRecordSp = gameOverNode.getChildByName("EndNode").getChildByName("NewRecordSp");
 
@@ -571,33 +573,33 @@ cc.Class({
     onShieldBtn: function () {
         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();
 
             //加载成功
             videoAd.onLoad(() => {
-                BK.Script.log(1,1,"videoAd onLoad")
+                BK.Script.log(1, 1, "videoAd onLoad")
             });
 
             //开始播放
             videoAd.onPlayStart(() => {
-                BK.Script.log(1,1,"videoAd onPlayStart")
+                BK.Script.log(1, 1, "videoAd onPlayStart")
             });
 
             //播放结束
             videoAd.onPlayFinish(() => {
-                BK.Script.log(1,1,"videoAd onPlayFinish")
+                BK.Script.log(1, 1, "videoAd onPlayFinish")
                 isFinish = true;
             });
 
             videoAd.onClose(() => {
-                if(isFinish) {
+                if (isFinish) {
                     // 看完15秒视频广告
                     // 可以下发游戏奖励
                     this.getShield();
@@ -611,7 +613,7 @@ cc.Class({
 
             videoAd.onError(function (err) {
                 //加载失败
-                BK.Script.log(1,1,"videoAd onError code:"+err.code+" msg:"+err.msg);
+                BK.Script.log(1, 1, "videoAd onError code:" + err.code + " msg:" + err.msg);
 
                 this.onPlayBtn()
             });
@@ -759,22 +761,22 @@ cc.Class({
 
             //加载成功
             videoAd.onLoad(() => {
-                BK.Script.log(1,1,"videoAd onLoad")
+                BK.Script.log(1, 1, "videoAd onLoad")
             });
 
             //开始播放
             videoAd.onPlayStart(() => {
-                BK.Script.log(1,1,"videoAd onPlayStart")
+                BK.Script.log(1, 1, "videoAd onPlayStart")
             });
 
             //播放结束
             videoAd.onPlayFinish(() => {
-                BK.Script.log(1,1,"videoAd onPlayFinish")
+                BK.Script.log(1, 1, "videoAd onPlayFinish")
                 isFinish = true;
             });
 
             videoAd.onClose(() => {
-                if(isFinish) {
+                if (isFinish) {
                     // 看完15秒视频广告
                     // 可以下发游戏奖励
                     this.continueGame();
@@ -787,7 +789,7 @@ cc.Class({
 
             videoAd.onError(function (err) {
                 //加载失败
-                BK.Script.log(1,1,"videoAd onError code:"+err.code+" msg:"+err.msg);
+                BK.Script.log(1, 1, "videoAd onError code:" + err.code + " msg:" + err.msg);
             });
 
             videoAd.show();