4 次代碼提交 355078b4b6 ... 3e24c871ad

作者 SHA1 備註 提交日期
  Roy 3e24c871ad Merge branch 'qqplay-1.0' of http://svn.ouj.com:3000/DWG/budingGame into qqplay-1.0 5 年之前
  Roy 9e3175b084 游戏结束展示 5 年之前
  Roy b258f2ec23 Merge branch 'qqplay-1.0' of http://svn.ouj.com:3000/DWG/budingGame into qqplay-1.0 5 年之前
  Roy 015225bdc5 游戏结束时的排行榜 5 年之前

文件差異過大導致無法顯示
+ 741 - 181
assets/Scene/GameSence.fire


+ 28 - 9
assets/Script/Game/GameOverItem.js

@@ -1,14 +1,33 @@
 cc.Class({
-  extends: cc.Component,
+    extends: cc.Component,
 
-  properties: {
-    sprite: cc.Sprite,
-    score: cc.Label,
-  },
+    properties: {
+        avatar: cc.Sprite,
+        scoreLabel: cc.Label,
+        nickLabel: cc.Label,
+        rankLabel: cc.Label,
+    },
 
-  // onLoad () {},
+    // onLoad () {},
 
-  start() {},
+    start() {},
 
-// update (dt) {},
-})
+    updateItem(data, i) {
+        this.scoreLabel.string = data.score;
+        this.nickLabel.string = data.nick;
+        this.rankLabel.string = i + 1;
+
+        cc.loader.load({
+            url: data.url,
+            type: 'jpg'
+        }, (err, texture) => {
+            if (err === undefined || err === null) {
+                this.avatar.spriteFrame = new cc.SpriteFrame(texture);
+            } else {
+                console.log(err);
+            }
+        });
+    },
+
+    // update (dt) {},
+})

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

@@ -0,0 +1,135 @@
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+        itemList: [cc.Node],
+    },
+
+    // onLoad () {},
+
+    onEnable() {
+        if (CC_QQPLAY) {
+            var attr = 'score'; // 使用哪一种上报数据做排行,可传入score,a1,a2等
+            var order = 1; // 排序的方法:[ 1: 从大到小(单局),2: 从小到大(单局),3: 由大到小(累积)]
+            var rankType = 0; // 要查询的排行榜类型,0: 好友排行榜
+            let self = this
+            BK.QQ.getRankListWithoutRoom(attr, order, rankType, function (errCode, cmd, data) {
+                // 返回错误码信息
+                if (errCode !== 0) {
+                    BK.Script.log(1, 1, '获取排行榜数据失败!错误码:' + errCode)
+                    return
+                }
+                // 解析数据
+                if (data) {
+                    self.bindRank(data.data.ranking_list);
+                }
+            })
+        } else {
+            let reponse = {
+                'errCode': 0,
+                'cmd': 'apollo_router_game.apollo_user_rankinglist_linkcmd_custom_ranking',
+                'data': {
+                    'data': {
+                        'ranking_list': [{
+                            'nick': '石达开',
+                            'url': 'http://img0.imgtn.bdimg.com/it/u=789186820,4034808660&fm=27&gp=0.jpg',
+                            'score': 1234,
+                            'a1': 121,
+                            'a2': 22,
+                            'selfFlag': true
+                        }, {
+                            'nick': '绝世佳人',
+                            'url': 'http://a.hiphotos.baidu.com/zhidao/pic/item/21a4462309f79052782f28490ff3d7ca7bcbd591.jpg',
+                            'score': 924,
+                            'a1': 101,
+                            'a2': 20,
+                            'selfFlag': false
+                        }, {
+                            'nick': '千山万水',
+                            'url': 'http://img5.imgtn.bdimg.com/it/u=1443063381,2025721196&fm=27&gp=0.jpg',
+                            'score': 712,
+                            'a1': 134,
+                            'a2': 24,
+                            'selfFlag': false
+                        }, {
+                            'nick': '三年二班',
+                            'url': 'http://img1.imgtn.bdimg.com/it/u=3463612537,3165214774&fm=27&gp=0.jpg',
+                            'score': 527,
+                            'a1': 167,
+                            'a2': 23,
+                            'selfFlag': false
+                        }, {
+                            'nick': 'henry',
+                            'url': 'http://img5.imgtn.bdimg.com/it/u=377014827,3751078472&fm=27&gp=0.jpg',
+                            'score': 327,
+                            'a1': 154,
+                            'a2': 32,
+                            'selfFlag': false
+                        }, {
+                            'nick': '图样图森破',
+                            'url': 'http://img2.imgtn.bdimg.com/it/u=1269743249,2763282807&fm=27&gp=0.jpg',
+                            'score': 227,
+                            'a1': 125,
+                            'a2': 86,
+                            'selfFlag': false
+                        }, {
+                            'nick': 'Mo_Bai',
+                            'url': 'http://img3.imgtn.bdimg.com/it/u=3166078695,1890527236&fm=27&gp=0.jpg',
+                            'score': 167,
+                            'a1': 138,
+                            'a2': 39,
+                            'selfFlag': false
+                        }]
+                    }
+                }
+            }
+            self.bindRank(reponse.data.data.ranking_list);
+        }
+    },
+
+
+    bindRank(rankList) {
+        for (var i = 0; i < rankList.length; ++i) {
+            var rd = rankList[i]
+            // rd 的字段如下:
+            // var rd = {
+            //    url: '',            // 头像的 url
+            //    nick: '',           // 昵称
+            //    score: 1,           // 分数
+            //    selfFlag: false,    // 是否是自己
+            // }
+            if (rd.selfFlag) {
+                if (i == 0) {
+                    for (var j = 0; j < this.itemList.length; j++) {
+                        let item = this.itemList[j];
+                        let rankIndex = j + i;
+                        if (rankIndex < rankList.length) {
+                            item.active = true;
+                            item.getComponent("GameOverItem").updateItem(rankList[rankIndex], rankIndex);
+                        } else {
+                            item.active = false;
+                        }
+                    }
+                } else {
+                    for (var j = 0; j < this.itemList.length; j++) {
+                        let item = this.itemList[j];
+                        let rankIndex = j + i - 1;
+                        if (rankIndex < rankList.length) {
+                            item.active = true;
+                            item.getComponent("GameOverItem").updateItem(rankList[rankIndex], rankIndex);
+                        } else {
+                            item.active = false;
+                        }
+                    }
+                }
+                break;
+            }
+        }
+    },
+
+
+
+    start() {},
+
+    // update (dt) {},
+})

+ 9 - 0
assets/Script/Game/GameOverRank.js.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.5",
+  "uuid": "d10ad99d-2518-4fac-9248-691f4f354ddd",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 72 - 70
assets/Script/Game/GameSence.js

@@ -218,12 +218,12 @@ cc.Class({
                 gameOverNode.getChildByName("EndNode").active = true;
 
                 this.gameOver();
-				
-				if (CC_QQPLAY) { 
-					this.rankScene.status = 3;
-					this.showRank();
-					this.updateXYXScore('showMyRank', null);
-				}
+
+                if (CC_QQPLAY) {
+                    this.rankScene.status = 3;
+                    this.showRank();
+                    this.updateXYXScore('showMyRank', null);
+                }
             } else {
                 countDown--;
                 countDownLabel.getComponent("cc.Label").string = countDown;
@@ -236,30 +236,30 @@ cc.Class({
     gameOver: function () {
         var gameOverNode = this.node.getChildByName("GameOver");
         var historyScoreLabel = gameOverNode.getChildByName("EndNode").getChildByName("HistoryScoreLabel");
-		var newRecordSp = gameOverNode.getChildByName("EndNode").getChildByName("NewRecordSp");
-		
-		UserInfo.getUserGameData((data) => {
-			var maxScore = data.maxScore || 0;
-			
-			if (this.sumScore > maxScore) {
-				maxScore = this.sumScore;
-				newRecordSp.active = true;
-				UserInfo.setUserGameData(this.sumScore);
-				
-				cc.audioEngine.playEffect(this.newRecordAudio);
-				newRecordSp.runAction(cc.repeatForever(cc.sequence(cc.scaleTo(0.5, 1.5), cc.scaleTo(0.5, 1))));
-			} else {
-				newRecordSp.active = false;
-			}
-	
-			if (this.sumScore > UserInfo.getScore()) {
-				UserInfo.setScore(this.sumScore);
-			}
-	
-			historyScoreLabel.getComponent("cc.Label").string = "历史最高分:" + maxScore;
-	
-			UserInfo.addGold(this.sumScore);
-		})
+        var newRecordSp = gameOverNode.getChildByName("EndNode").getChildByName("NewRecordSp");
+
+        UserInfo.getUserGameData((data) => {
+            var maxScore = data.maxScore || 0;
+
+            if (this.sumScore > maxScore) {
+                maxScore = this.sumScore;
+                newRecordSp.active = true;
+                UserInfo.setUserGameData(this.sumScore);
+
+                cc.audioEngine.playEffect(this.newRecordAudio);
+                newRecordSp.runAction(cc.repeatForever(cc.sequence(cc.scaleTo(0.5, 1.5), cc.scaleTo(0.5, 1))));
+            } else {
+                newRecordSp.active = false;
+            }
+
+            if (this.sumScore > UserInfo.getScore()) {
+                UserInfo.setScore(this.sumScore);
+            }
+
+            historyScoreLabel.getComponent("cc.Label").string = "历史最高分:" + maxScore;
+
+            UserInfo.addGold(this.sumScore);
+        })
 
         // window.deadBanner.hide();
         // window.accountBanner.show();
@@ -291,7 +291,7 @@ cc.Class({
         this.node.runAction(cc.sequence(cc.delayTime(1), cc.callFunc(this.createObstacle, this), cc.delayTime(1), cc.callFunc(this.createObstacle, this)));
     },
 
-	// 创建障碍物
+    // 创建障碍物
     createObstacle: function () {
         var obstacleType = this.randomObstacleType();
         //根据当前分数控制障碍物之间的高度
@@ -396,7 +396,7 @@ cc.Class({
         })
     },
 
-	// 随机生成障碍物类型
+    // 随机生成障碍物类型
     randomObstacleType: function () {
         var obstacleType = 0;
         this.obstacleNum++;
@@ -447,7 +447,7 @@ cc.Class({
         return obstacleType;
     },
 
-	// 销毁障碍物
+    // 销毁障碍物
     destroyObstacle: function () {
         let obstacle1 = this.obstacleNode.getChildByName("obstacle1"),
             obstacle2 = this.obstacleNode.getChildByName("obstacle2"),
@@ -715,15 +715,15 @@ cc.Class({
                 imgurlData: UserInfo.shareUrl,
                 queryData: 'pp=pp'
             }
-            
+
             QQCommon.ShareAppMessage(data, () => {
-				var gameOverNode = this.node.getChildByName("GameOver");
-				var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");
-				countDownLabel.stopAllActions();
-				this.continueGame();
+                var gameOverNode = this.node.getChildByName("GameOver");
+                var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");
+                countDownLabel.stopAllActions();
+                this.continueGame();
 
-				cc.audioEngine.playMusic(this.gamebgMusic, true);
-			});
+                cc.audioEngine.playMusic(this.gamebgMusic, true);
+            });
         } else {
             var gameOverNode = this.node.getChildByName("GameOver");
             var countDownLabel = gameOverNode.getChildByName("ShareNode").getChildByName("EndCountDownLabel");
@@ -845,13 +845,13 @@ cc.Class({
         gameOverNode.getChildByName("EndNode").active = true;
 
         this.gameOver();
-		
-		if (CC_QQPLAY) { 
+
+        if (CC_QQPLAY) {
             // window.deadBanner.hide();
-			this.rankScene.status = 3;
+            this.rankScene.status = 3;
             this.showRank();
             this.updateXYXScore('showMyRank', null);
-		}
+        }
     },
 
     onRestartBtn: function () {
@@ -893,31 +893,33 @@ cc.Class({
     },
 
     updateXYXScore(strFun, data) {
-		var data = {
-			userData: [{
-				openId: GameStatusInfo.openId,
-				startMs: GameStatusInfo.startMs,
-				endMs: ((new Date()).getTime()).toString(),
-				scoreInfo: {
-					score: parseInt(UserInfo.getScore()), //分数,类型必须是整型数
-				}
-			}],
-			attr: {
-				score: {   
-					type: 'rank',
-					order: 1,
-				}
-			},
-		};
-
-		BK.QQ.uploadScoreWithoutRoom(1, data, function(errCode, cmd, data) {
-			// 返回错误码信息
-			if (errCode !== 0) {
-				BK.Script.log(1,1,'上传分数失败!错误码:' + errCode);
-			} else {
-				BK.Script.log(1,1,'上传分数成功' + JSON.stringify(data));
-			}
-		});
+        var data = {
+            userData: [{
+                openId: GameStatusInfo.openId,
+                startMs: GameStatusInfo.startMs,
+                endMs: ((new Date()).getTime()).toString(),
+                scoreInfo: {
+                    score: parseInt(UserInfo.getScore()), //分数,类型必须是整型数
+                }
+            }],
+            attr: {
+                score: {
+                    type: 'rank',
+                    order: 1,
+                }
+            },
+        };
+
+        if (CC_QQPLAY) {
+            BK.QQ.uploadScoreWithoutRoom(1, data, function (errCode, cmd, data) {
+                // 返回错误码信息
+                if (errCode !== 0) {
+                    BK.Script.log(1, 1, '上传分数失败!错误码:' + errCode);
+                } else {
+                    BK.Script.log(1, 1, '上传分数成功' + JSON.stringify(data));
+                }
+            });
+        }
     },
 
     showRank() {
@@ -998,4 +1000,4 @@ cc.Class({
         // }
 
     },
-});
+});

+ 3 - 10
assets/Script/Rank/RankItem.js

@@ -1,5 +1,3 @@
-
-
 cc.Class({
     extends: cc.Component,
 
@@ -36,14 +34,9 @@ cc.Class({
         this.scoreLabel.string = data.score;
         this.nameLabel.string = data.nick;
 
-
-        if (CC_QQPLAY) {
-            var img = BK.Image.loadImage("GameRes://texture/icon.png");
-            this.avatar.spriteFrame = new cc.SpriteFrame(img);
-        }
-
         cc.loader.load({
-            url: data.url, type: 'jpg'
+            url: data.url,
+            type: 'jpg'
         }, (err, texture) => {
             if (err === undefined || err === null) {
                 this.avatar.spriteFrame = new cc.SpriteFrame(texture);
@@ -54,4 +47,4 @@ cc.Class({
     }
 
     // update (dt) {},
-});
+});

部分文件因文件數量過多而無法顯示