| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { _decorator, Component, Label, Node, tween, Vec3 } from "cc"
- const { ccclass, property } = _decorator
- @ccclass("rankCtr")
- export class rankCtr extends Component {
- @property({ type: Node })
- public textLiveRank: Node | null = null
- @property({ type: Node })
- public rankNods: Node[] = []
- @property({ type: Node })
- public textPointsRank: Node | null = null
- private isLiveRank: boolean = true
- private moveDistance: number = -150
- private lng:string = 'cn'
- start() {}
- // 触发方法
- updateRankTop() {
- this.isLiveRank = !this.isLiveRank
- this.updateRankDisplay()
- }
- private updateRankDisplay() {
- if (!this.textLiveRank || !this.textPointsRank) return
- let moveOffset = this.isLiveRank ? -this.moveDistance : this.moveDistance
- let moveAction = new Vec3(moveOffset, 0, 0)
- tween(this.textLiveRank).by(0.5, { position: moveAction }).start()
- tween(this.textPointsRank).by(0.5, { position: moveAction }).start()
- }
- updateRank(data:any[])
- {
- for(let i=0;i<6;i++)
- {
- const nameLebel= this.rankNods[i].getChildByName("text_player_name").getComponent(Label);
- const days= this.rankNods[i].getChildByName("text_value").getComponent(Label);
- if(data.length > i)
- {
- nameLebel.string = data[i].userInfo.name
- if(this.lng === 'cn')
- {
- days.string = data[i].survival + '天'
- }
- else{
- days.string = data[i].survival + (data[i].survival == '1' ? 'day' : 'days' )
- }
-
- }
- }
- }
- update(deltaTime: number) {}
- }
|