const {ccclass, property} = cc._decorator; @ccclass export default class NewClass extends cc.Component { @property(cc.Label) count: cc.Label = null; @property(cc.Label) time: cc.Label = null; @property(cc.Node) selfNode: cc.Node = null; @property(cc.Node) one: cc.Node = null; @property(cc.Node) two: cc.Node = null; @property(cc.Node) three: cc.Node = null; @property(cc.Node) four: cc.Node = null; @property(cc.Node) five: cc.Node = null; listData: any; selfData: any; // onLoad () {} start () { this.count.string = cc.fx.GameConfig.GM_INFO.score + ""; var yes = 0; var successList = cc.fx.GameConfig.GM_INFO.successList; if(successList.length > 0){ var success = 0; for(let i=0; ithis.getRankData(data)); } //设置排行信息 getRankData(data){ if(data){ cc.fx.GameTool.getRankData(data,this,4); cc.fx.GameTool.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"),this.selfData.pic); var length = data.length; if(length > 4) length = 4; for(let i=0;i<=length;i++){ this.setRank(i,this.listData[i]); } } } //根据内容填充排行榜 setRank(num,data){ var hitNode = null; if(num == 0){ hitNode = this.one; } else if(num == 1){ hitNode = this.two; } else if(num == 2){ hitNode = this.three; } else if(num == 3){ hitNode = this.four; } else if(num == 4){ hitNode = this.five; } if(hitNode){ hitNode.active = true; if(data.nickName.length >= 4) cc.fx.GameTool.subName(data.nickName,4); hitNode.getChildByName("name").getComponent(cc.Label).string = data.nickName; hitNode.getChildByName("total").getComponent(cc.Label).string = data.totalSunCount; cc.fx.GameTool.setPic(hitNode.getChildByName("pic").getChildByName("icon"),data.pic); } } }