| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559 |
- window.bTurnsNumber = false;
- window.calorie = 0
- window.turnsNum = 0
- window.direction = 1
- window.turnsNumber = function (turns){
- if(window.bTurnsNumber)
- {
- console.log("turnsNumber:",turns);
- if(window.isAndroid)
- window.hardWare = turns
- else if(window.isiOS)
- window.hardWare = JSON.parse(turns)
- window.calorie = window.hardWare.calorie
- window.turnsNum = window.hardWare.turnsnumber
- window.direction = window.hardWare.direction
- }
- }
- window.submitScoreResponse = function(response){
- console.log('submitScoreResponse:',response)
- }
- window.submitScoreOnError= function(response){
- console.log('submitScoreOnError:',response)
- }
- var GameStates = require('GameStates');
- cc.Class({
- extends: cc.Component,
- properties: {
- bg:cc.Node,
- Champin:cc.Node,
- rankPanel:cc.Node,
- maxScoreLabel:cc.Label,
- monthRankContent:cc.Node,
- legendRankContent:cc.Node,
- crownFrame:[cc.SpriteFrame],
- numberFrame:[cc.SpriteFrame],
- headFrame:[cc.SpriteFrame],
- rankList:[cc.Prefab],
- myRank:cc.Node,
- //音效
- sound:{
- default:[],
- type: cc.AudioClip
- },
- bgsound:{
- default:[],
- type: cc.AudioClip
- },
- },
- // LIFE-CYCLE CALLBACKS:
-
- onLoad () {
- this.isAndroid = false;
- this.isiOS = false;
- window.isiOS = false
- window.isAndroid = false;
- console.log('平台信息=',navigator.userAgent);
- this.isAndroid = Boolean(navigator.userAgent.match(/android/ig));
- window.isAndroid = this.isAndroid
- this.isIphone = Boolean(navigator.userAgent.match(/iphone|ipod/ig));
- this.isIpad = Boolean(navigator.userAgent.match(/ipad/ig));
- if(this.isIphone || this.isIpad)
- {
- this.isiOS = true;
- window.isiOS = true
- }
-
- if(this.isAndroid)
- {
- console.log('当前平台是:android')
- }
- else if(this.isiOS)
- {
- console.log('当前平台是:ios')
- }
- else
- {
- console.log('当前平台未检测到')
- }
- },
- start () {
- if(cc.sys.localStorage.getItem('levelNumber')==null || cc.sys.localStorage.getItem('levelNumber')==''){
- cc.sys.localStorage.setItem('levelNumber',1)
- cc.sys.localStorage.setItem('showRank',0)
- }
- GameStates.levelNum = parseInt(cc.sys.localStorage.getItem('levelNumber'))
- GameStates.gameScore = 0
- this.node.getChildByName('Loading').active = true
- this.node.getChildByName('Loading').getChildByName('DOT0').runAction(cc.repeatForever(cc.sequence(cc.delayTime(0),cc.fadeIn(0),cc.delayTime(1.5),cc.fadeOut(0),cc.delayTime(0.5))))
- this.node.getChildByName('Loading').getChildByName('DOT1').runAction(cc.repeatForever(cc.sequence(cc.delayTime(0.5),cc.fadeIn(0),cc.delayTime(1),cc.fadeOut(0),cc.delayTime(0.5))))
- this.node.getChildByName('Loading').getChildByName('DOT2').runAction(cc.repeatForever(cc.sequence(cc.delayTime(1),cc.fadeIn(0),cc.delayTime(0.5),cc.fadeOut(0),cc.delayTime(0.5))))
-
- var sceneName = 'GameScene'
- this.preloadScene(sceneName)
- if(parseInt(cc.sys.localStorage.getItem('showRank'))==1){
- this.monthRank()
- this.rankPanel.active = true
- cc.sys.localStorage.setItem('showRank',0)
- }
- //关卡音乐
- cc.audioEngine.play(this.bgsound[0],true)
- if(!((this.isAndroid && window.eventJsBridge.maxScore) || (this.isiOS && window.webkit.messageHandlers.maxScore))){
- this.Champin.active = false
- }
- else{
- if(this.isAndroid)
- {
- console.log('maxScore')
- window.eventJsBridge.maxScore()
- }
- else if(this.isiOS)
- {
- console.log('maxScore')
- window.webkit.messageHandlers.maxScore.postMessage(null);
- }
- var self = this
- window.maxScore = function(maxScore){
- console.log('maxScore',maxScore)
- if(self.isAndroid){
- var mymaxScore = maxScore
- self.maxScoreLabel.string = mymaxScore.maxScore
- }
- else if(self.isiOS){
- var mymaxScore = JSON.parse(maxScore)
- self.maxScoreLabel.string = mymaxScore.maxScore
- }
- }
- }
-
-
- // var myRank = {}
- // myRank.portraits = 'https://dn-qn.move-it.club/syshead12006.jpg'
- // if(myRank.portraits.substring(myRank.portraits.length-4,myRank.portraits.length)=='.png' || myRank.portraits.substring(myRank.portraits.length-4,myRank.portraits.length)=='.jpg')
- // cc.loader.load({url: myRank.portraits}, function (err, frame) {
- // })
- // else
- // cc.loader.load({url: myRank.portraits, type: 'png'}, function (err, frame) {
- // cc.log(new cc.SpriteFrame(frame))
- // })
- },
- gameBegin(){
- //接口
- if(this.isAndroid)
- {
- console.log('isSendData')
- window.eventJsBridge.isSendData(true)
- }
- else if(this.isiOS)
- {
- console.log('isSendData')
- window.webkit.messageHandlers.isSendData.postMessage(true);
- }
- cc.audioEngine.play(this.sound[0],false)
- GameStates.gameTime = new Date()
- GameStates.levelNum = 1
- GameStates.lifeNum = 3
- GameStates.carlNum = window.calorie
- GameStates.turnsNum = window.turnsNum
- cc.director.loadScene('GameScene')
- },
- gameRank(){
- cc.audioEngine.play(this.sound[0],false)
- this.monthRank()
- this.rankPanel.active = true
- },
- gameHome(){
- cc.audioEngine.play(this.sound[0],false)
- // cc.director.loadScene('BeginScene')
- },
- gameBack(){
- if(this.isAndroid)
- {
- window.eventJsBridge.goBack()
- }
- else if(this.isiOS)
- {
- window.webkit.messageHandlers.goBack.postMessage(null)
- }
- },
- onDestroy(){
- cc.audioEngine.stopAllEffects()
- },
- preloadScene (sceneName, onLoaded) {
- var info = cc.director._getSceneUuid(sceneName);
- if (info) {
- cc.director.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING, sceneName);
- cc.loader.load({ uuid: info.uuid, type: 'uuid' },
-
- (completedCount, totalCount, item) => {
- let _loadingNextStep = (completedCount / totalCount * 100);
- this.node.getChildByName('Loading').getChildByName('ProgressBar').getComponent(cc.ProgressBar).progress = (_loadingNextStep/100)
- // cc.log(this.node.getChildByName('ProgressBar').getComponent(cc.ProgressBar).progress,(_loadingNextStep/100))
- if(Math.floor(_loadingNextStep)==100){
- this.node.getChildByName('Loading').active = false
- }
- }
- , function (error, asset) {
- if (error) {
- }
- if (onLoaded) {
- onLoaded(error, asset);
- }
- });
- }
- else {
- onLoaded(new Error());
- }
- },
- closeRank(){
- cc.audioEngine.play(this.sound[0],false)
- this.rankPanel.active = false
- },
- legendRank(){
- cc.audioEngine.play(this.sound[0],false)
- this.rankPanel.getChildByName('legendRank').active = true
- this.rankPanel.getChildByName('monthRank').active = false
- this.rankPanel.getChildByName('monthBtn0').active = true
- this.rankPanel.getChildByName('monthBtn1').active = false
- this.rankPanel.getChildByName('legendBtn0').active = false
- this.rankPanel.getChildByName('legendBtn1').active = true
- this.legendRankContent.parent.parent.getComponent(cc.ScrollView).setContentPosition(cc.v2(0,350))
-
- var str = '{"myRanking":{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807},'+
- '"rankingList":[{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":2,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":3,"score":700,"userId":22978961616130},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":4,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":5,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":6,"score":700,"userId":22978961616130},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":7,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":8,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":9,"score":700,"userId":22978961616130},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":10,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":11,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":12,"score":700,"userId":22978961616130}]}'
- var str = '{"myRanking":{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807},'+
- '"rankingList":[{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807}]}'
-
- var self = this
- this.monthRankContent.removeAllChildren()
- this.legendRankContent.removeAllChildren()
- if(this.isAndroid)
- {
- console.log('getRankingList2')
- window.eventJsBridge.getRankingList(2)
- }
- else if(this.isiOS)
- {
- console.log('getRankingList2')
- window.webkit.messageHandlers.getRankingList.postMessage(2);
- }
- window.rankingResponse= function(response){
- console.log('rankin:',response)
- if(self.isAndroid)
- window.ranking = response
- else if(self.isiOS)
- window.ranking = JSON.parse(response)
- var myRank = window.ranking.myRanking
- var rankingList = window.ranking.rankingList
- // var myRank = JSON.parse(str).myRanking
- // var rankingList = JSON.parse(str).rankingList
- self.rankingList = rankingList
- self.myRank.getChildByName('name').getComponent(cc.Label).string = myRank.nickName
- self.myRank.getChildByName('score').getComponent(cc.Label).string = myRank.score+'分'
- self.myRank.getChildByName('rank').getComponent(cc.Label).string = myRank.rank
- if(!myRank.sex){
- myRank.sex = 1
- }
- if(myRank.portraits.substring(myRank.portraits.length-4,myRank.portraits.length)=='.png' || myRank.portraits.substring(myRank.portraits.length-4,myRank.portraits.length)=='.jpg')
- cc.loader.load({url: myRank.portraits}, function (err, frame) {
- if(err)
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = self.headFrame[myRank.sex-1]
- else
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(frame)
- })
- else
- cc.loader.load({url: myRank.portraits, type: 'png'}, function (err, frame) {
- if(err)
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = self.headFrame[myRank.sex-1]
- else
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(frame)
- })
- console.log(rankingList)
- //排序
- for(var m=0;m<rankingList.length-1;m++){
- for(var n=0;n<rankingList.length-1;n++){
- var namenum = parseInt(rankingList[n].rank)
- var namenum1 = parseInt(rankingList[n+1].rank)
- if(namenum>namenum1){
- var rankList = rankingList[n]
- rankingList[n] = rankingList[n+1]
- rankingList[n+1] = rankList
- }
- }
- }
- //加载
- var i = 0
- self.legendRankContent.height = rankingList.length*120
- self.rankListarr = []
- var showRankingList = function(){
- if(!rankingList[i].sex){
- rankingList[i].sex = 1
- }
- if(rankingList[i].portraits.substring(rankingList[i].portraits.length-4,rankingList[i].portraits.length)=='.png' || rankingList[i].portraits.substring(rankingList[i].portraits.length-4,rankingList[i].portraits.length)=='.jpg')
- cc.loader.load({url: rankingList[i].portraits}, function (err, frame) {
- if(err)
- rankingList[i].frame = self.headFrame[rankingList[i].sex-1]
- else
- rankingList[i].frame = new cc.SpriteFrame(frame)
- i++
- self.topindex = 0
- if(i<rankingList.length)
- showRankingList()
- else
- self.showrankListarr(self.legendRankContent)
- })
- else
- cc.loader.load({url: rankingList[i].portraits, type: 'png'}, function (err, frame) {
- if(err)
- rankingList[i].frame = self.headFrame[rankingList[i].sex-1]
- else
- rankingList[i].frame = new cc.SpriteFrame(frame)
- i++
- self.topindex = 0
- if(i<rankingList.length)
- showRankingList()
- else
- self.showrankListarr(self.legendRankContent)
- })
- }
- showRankingList()
- }
- // window.rankingResponse()
- },
- monthRank(){
- cc.audioEngine.play(this.sound[0],false)
- this.rankPanel.getChildByName('legendRank').active = false
- this.rankPanel.getChildByName('monthRank').active = true
- this.rankPanel.getChildByName('monthBtn0').active = false
- this.rankPanel.getChildByName('monthBtn1').active = true
- this.rankPanel.getChildByName('legendBtn0').active = true
- this.rankPanel.getChildByName('legendBtn1').active = false
- this.monthRankContent.parent.parent.getComponent(cc.ScrollView).setContentPosition(cc.v2(0,350))
- var str = '{"myRanking":{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807},'+
- '"rankingList":[{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":2,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":3,"score":700,"userId":22978961616130},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":4,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":5,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":6,"score":700,"userId":22978961616130},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":7,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":8,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":9,"score":700,"userId":22978961616130},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":10,"score":1000,"userId":14624607179958807},'+
- '{"nickName":"乙","portraits":"https://dn-qn.move-it.club/syshead12009.jpg","rank":11,"score":800,"userId":11618408636521789},'+
- '{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12006.jpg","rank":12,"score":700,"userId":22978961616130}]}'
- // var str = '{"myRanking":{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807},'+
- // '"rankingList":[{"nickName":"甲","portraits":"https://dn-qn.move-it.club/syshead12001.jpg","rank":1,"score":1000,"userId":14624607179958807}]}'
-
- var self = this
- this.monthRankContent.removeAllChildren()
- this.legendRankContent.removeAllChildren()
- if(this.isAndroid)
- {
- console.log('getRankingList1')
- window.eventJsBridge.getRankingList(1)
- }
- else if(this.isiOS)
- {
- console.log('getRankingList1')
- window.webkit.messageHandlers.getRankingList.postMessage(1);
- }
- window.rankingResponse= function(response){
- console.log('rankin:',response)
- if(self.isAndroid)
- window.ranking = response
- else if(self.isiOS)
- window.ranking = JSON.parse(response)
- var myRank = window.ranking.myRanking
- var rankingList = window.ranking.rankingList
- // var myRank = JSON.parse(str).myRanking
- // var rankingList = JSON.parse(str).rankingList
- self.rankingList = rankingList
- self.myRank.getChildByName('name').getComponent(cc.Label).string = myRank.nickName
- self.myRank.getChildByName('score').getComponent(cc.Label).string = myRank.score+'分'
- self.myRank.getChildByName('rank').getComponent(cc.Label).string = myRank.rank
- if(!myRank.sex){
- myRank.sex = 1
- }
- if(myRank.portraits.substring(myRank.portraits.length-4,myRank.portraits.length)=='.png' || myRank.portraits.substring(myRank.portraits.length-4,myRank.portraits.length)=='.jpg')
- cc.loader.load({url: myRank.portraits}, function (err, frame) {
- if(err)
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = self.headFrame[myRank.sex-1]
- else
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(frame)
- })
- else
- cc.loader.load({url: myRank.portraits, type: 'png'}, function (err, frame) {
- if(err)
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = self.headFrame[myRank.sex-1]
- else
- self.myRank.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(frame)
- })
- console.log(rankingList)
- //排序
- for(var m=0;m<rankingList.length-1;m++){
- for(var n=0;n<rankingList.length-1;n++){
- var namenum = parseInt(rankingList[n].rank)
- var namenum1 = parseInt(rankingList[n+1].rank)
- if(namenum>namenum1){
- var rankList = rankingList[n]
- rankingList[n] = rankingList[n+1]
- rankingList[n+1] = rankList
- }
- }
- }
- //加载
- var i = 0
- self.monthRankContent.height = rankingList.length*120
- self.rankListarr = []
- var showRankingList = function(){
- if(!rankingList[i].sex){
- rankingList[i].sex = 1
- }
- if(rankingList[i].portraits.substring(rankingList[i].portraits.length-4,rankingList[i].portraits.length)=='.png' || rankingList[i].portraits.substring(rankingList[i].portraits.length-4,rankingList[i].portraits.length)=='.jpg')
- cc.loader.load({url: rankingList[i].portraits}, function (err, frame) {
- if(err)
- rankingList[i].frame = self.headFrame[rankingList[i].sex-1]
- else
- rankingList[i].frame = new cc.SpriteFrame(frame)
- i++
- self.topindex = 0
- if(i<rankingList.length)
- showRankingList()
- else
- self.showrankListarr(self.monthRankContent)
- })
- else
- cc.loader.load({url: rankingList[i].portraits, type: 'png'}, function (err, frame) {
- if(err)
- rankingList[i].frame = self.headFrame[rankingList[i].sex-1]
- else
- rankingList[i].frame = new cc.SpriteFrame(frame)
- i++
- self.topindex = 0
- if(i<rankingList.length)
- showRankingList()
- else
- self.showrankListarr(self.monthRankContent)
- })
- }
- showRankingList()
- }
- // window.rankingResponse()
- },
- showrankListarr(content){
- var self = this
- for(var j=0;j<10;j++){
- if(j>=this.rankingList.length)
- return
- var rankList = cc.instantiate(self.rankList[0])
- rankList.index = j
- rankList.parent = content
- rankList.y = -j*120-70
- if(j==0)
- self.topItem = rankList
- if(j==9)
- self.bottomItem = rankList
- var rankingList = this.rankingList
- cc.log(rankingList,rankList.index,self.topindex)
- rankList.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = rankingList[(rankList.index+self.topindex)].frame
- rankList.getChildByName('name').getComponent(cc.Label).string = rankingList[(rankList.index+self.topindex)].nickName
- rankList.getChildByName('score').getComponent(cc.Label).string = rankingList[(rankList.index+self.topindex)].score
- rankList.getChildByName('rank').getComponent(cc.Label).string = rankingList[(rankList.index+self.topindex)].rank
- if((rankList.index+self.topindex)<3){
- rankList.getChildByName('crown').active = true
- rankList.getChildByName('number').active = true
- rankList.getChildByName('crown').getComponent(cc.Sprite).spriteFrame = self.crownFrame[(rankList.index+self.topindex)]
- rankList.getChildByName('number').getComponent(cc.Sprite).spriteFrame = self.numberFrame[(rankList.index+self.topindex)]
- rankList.getChildByName('num').active = false
- rankList.getChildByName('rank').active = false
- }
- else{
- rankList.getChildByName('crown').active = false
- rankList.getChildByName('number').active = false
- rankList.getChildByName('num').active = true
- }
- self.rankListarr.push(rankList)
- }
- },
- update(){
- if(this.rankPanel.getChildByName('legendRank').active)
- var height = this.legendRankContent.parent.parent.getComponent(cc.ScrollView).getContentPosition().y
- else
- var height = this.monthRankContent.parent.parent.getComponent(cc.ScrollView).getContentPosition().y
- if(height>(420+120*(this.topindex+1)) && this.topindex<this.rankingList.length-10){
- this.topindex++
- this.topItem.y = this.bottomItem.y-120
- this.bottomItem = this.topItem
- var n = (this.topItem.index+1)>9?0:this.topItem.index+1
- this.topItem = this.rankListarr[n]
- var rankList = this.bottomItem
- var rankingList = this.rankingList
- cc.log(this.topItem.y)
- rankList.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = rankingList[this.topindex+9].frame
- rankList.getChildByName('name').getComponent(cc.Label).string = rankingList[(this.topindex+9)].nickName
- rankList.getChildByName('score').getComponent(cc.Label).string = rankingList[(this.topindex+9)].score
- rankList.getChildByName('rank').getComponent(cc.Label).string = rankingList[(this.topindex+9)].rank
- if((this.topindex+9)<3){
- rankList.getChildByName('crown').active = true
- rankList.getChildByName('number').active = true
- rankList.getChildByName('crown').getComponent(cc.Sprite).spriteFrame = this.crownFrame[(this.topindex+9)]
- rankList.getChildByName('number').getComponent(cc.Sprite).spriteFrame = this.numberFrame[this.topindex+9]
- rankList.getChildByName('num').active = false
- rankList.getChildByName('rank').active = false
- }
- else{
- rankList.getChildByName('crown').active = false
- rankList.getChildByName('number').active = false
- rankList.getChildByName('num').active = true
- rankList.getChildByName('rank').active = true
- }
- }
- if(height<(300+120*(this.topindex+1)) && this.topindex>0){
- this.topindex--
- this.bottomItem.y = this.topItem.y+120
- this.topItem = this.bottomItem
- var n = (this.bottomItem.index-1)<0?9:this.bottomItem.index-1
- this.bottomItem = this.rankListarr[n]
- var rankList = this.topItem
- var rankingList = this.rankingList
- cc.log(rankingList[this.topindex])
- rankList.getChildByName('mask').getChildByName('head').getComponent(cc.Sprite).spriteFrame = rankingList[this.topindex].frame
- rankList.getChildByName('name').getComponent(cc.Label).string = rankingList[(this.topindex)].nickName
- rankList.getChildByName('score').getComponent(cc.Label).string = rankingList[(this.topindex)].score
- rankList.getChildByName('rank').getComponent(cc.Label).string = rankingList[(this.topindex)].rank
- if((this.topindex)<3){
- rankList.getChildByName('crown').active = true
- rankList.getChildByName('number').active = true
- rankList.getChildByName('crown').getComponent(cc.Sprite).spriteFrame = this.crownFrame[(this.topindex)]
- rankList.getChildByName('number').getComponent(cc.Sprite).spriteFrame = this.numberFrame[this.topindex]
- rankList.getChildByName('num').active = false
- rankList.getChildByName('rank').active = false
- }
- else{
- rankList.getChildByName('crown').active = false
- rankList.getChildByName('number').active = false
- rankList.getChildByName('num').active = true
- rankList.getChildByName('rank').active = true
- }
- }78
- }
- });
|