/** * 顶部 等级 进度条 */ import PlayData from "../../Tools/PlayData"; const {ccclass, property} = cc._decorator; @ccclass export default class LevelBarSc extends cc.Component { @property([cc.SpriteFrame]) diansp:cc.SpriteFrame[] = [] @property(cc.Node) tishikuang:cc.Node = null @property([cc.SpriteFrame]) paiSp:cc.SpriteFrame[] = [] jindu = 0 levelnum = [] pailevel = [5,6,7,9,10] onLoad () { //this.jindu = 0 this.initLevelBar() this.updateLevelBar() } start () { } /** * 初始化 */ initLevelBar(){ //console.log('打印guanqia,jindu', PlayData.Instance.guanqia, this.jindu) let guanqia = 5+5*PlayData.Instance.guanqia+PlayData.Instance.guanqia for (let index = 0; index < 5; index++) { let dian = cc.find('dian' + index, this.node) let numstr = cc.find('numstr', dian).getComponent(cc.Label) numstr.string = '' + guanqia this.levelnum[index] = guanqia if(index == 2){ guanqia += 2 }else{guanqia += 1} } } /** * 更新 */ updateLevelBar(){ console.log('updateLevelBar', this.jindu) for (let index = 0; index < 4; index++) { let diansp = cc.find('dian' + index, this.node).getComponent(cc.Sprite) let ani = diansp.node.getComponent(cc.Animation) if(index == this.jindu){ //diansp.spriteFrame = this.diansp[1] ani.play() this.tishikuang.active = !0 this.tishikuang.opacity = 0 cc.tween(this.tishikuang) .delay(1) .to(0.3, {opacity:255}) .delay(3) .call(()=>{ this.tishikuang.active = !1 }) .start() //let tishistr = cc.find('tishistr', this.tishikuang).getComponent(cc.Label) //tishistr.string = '下一个目标:' + this.levelnum[index] + ' 解锁新空位!' //tishistr.string = '下一个目标: ' + ' 解锁新空位!' let nexticon = cc.find('nexticon', this.tishikuang).getComponent(cc.Sprite) nexticon.spriteFrame = this.paiSp[this.jindu] }else if(index > this.jindu){ //diansp.spriteFrame = this.diansp[3] ani.stop() }else if(index < this.jindu){ diansp.spriteFrame = this.diansp[0] ani.stop() } } } // update (dt) {} }