Selaa lähdekoodia

排行榜数据修改

Roy 5 vuotta sitten
vanhempi
commit
f99c6a2c2d
2 muutettua tiedostoa jossa 27 lisäystä ja 1 poistoa
  1. 25 0
      assets/Script/Game/GameOverRank.js
  2. 2 1
      assets/Script/Game/GameSence.js

+ 25 - 0
assets/Script/Game/GameOverRank.js

@@ -3,6 +3,7 @@ cc.Class({
 
     properties: {
         itemList: [cc.Node],
+        myScore: -1,
     },
 
     // onLoad () {},
@@ -89,6 +90,27 @@ cc.Class({
 
 
     bindRank(rankList) {
+
+        if (this.myScore >= 0) {
+            for (var i = 0; i < rankList.length; i++) {
+                if (rd.selfFlag) {
+                    rankList[i].score = this.myScore;
+                }
+            }
+            rankList.sort((a, b) => {
+                if (a.length == 0 && b.length == 0) {
+                    return 0;
+                }
+                if (a.length == 0) {
+                    return 1;
+                }
+                if (b.length == 0) {
+                    return -1;
+                }
+                return b.score - a.score;
+            });
+        }
+
         for (var i = 0; i < rankList.length; ++i) {
             var rd = rankList[i]
             // rd 的字段如下:
@@ -128,6 +150,9 @@ cc.Class({
     },
 
 
+    setMyScore(score) {
+        this.myScore = score;
+    },
 
     start() {},
 

+ 2 - 1
assets/Script/Game/GameSence.js

@@ -191,9 +191,10 @@ cc.Class({
             }
             this.startFinishCount();
         } else {
+            gemeOverNode.getChildByName("OverBg").getComponent("GameOverRank").setMyScore(parseInt(UserInfo.getScore()));
             gameOverNode.getChildByName("EndNode").active = true;
             gameOverNode.getChildByName("ShareNode").active = false;
-
+            
             this.gameOver();
 
             if (CC_QQPLAY) {