123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { _decorator, Component, Label, Node, Sprite, tween, UITransform, Vec3 } from 'cc';
- import { uiManager } from '../../manager/uiManager';
- import { rankData } from '../../data';
- import { GameManager } from '../../GameManager';
- import { tools } from '../../tools';
- import { dataManager } from '../../manager/dataManager';
- const { ccclass, property } = _decorator;
- @ccclass('home_bottom_rank_item')
- export class home_bottom_rank_item extends Component {
- @property(Node) img_car:Node = null
- @property(Node) lab_nickname:Node = null
- @property(Node) lab_score:Node = null
- @property(Node) lab_jiancheng:Node = null
- private m_data:rankData = null
- private m_cb = null
- protected start(): void {
- uiManager.Instance().onButtonListen(this.node, ()=>{
- if(this.m_cb!=null) {
- this.m_cb(this)
- }
- })
- }
- public initView(data:rankData, cb) {
- this.m_data = data
- this.m_cb = cb
- this.img_car.getComponent(Sprite).spriteFrame = dataManager.getUserRankCarSf(data.car_id, data.user_id)
- tools.labelCutString(this.lab_nickname,data.nickName,5)
- this.lab_score.getComponent(Label).string = data.score + '分'
- this.lab_jiancheng.getComponent(Label).string = data.province_code
- }
- public getData():rankData {
- return this.m_data
- }
- public startAnimation(timeout:number) {
- let origin_pos = this.node.getPosition()
- let y = origin_pos.y - this.node.getComponent(UITransform).height - 80
- let init_pos = new Vec3(origin_pos.x,y,0)
- this.node.setPosition(init_pos)
- setTimeout(()=>{
- tween(this.node).to(0.25,{position: new Vec3(origin_pos.x,origin_pos.y,0)}).start()
- },timeout)
- }
- }
|