games/FullFire/assets/scripts/RankingItem.ts

49 lines
1.5 KiB
TypeScript

import PlayerData from "./PlayerData";
import Main from "../Main";
import WXHelper from "./common/WXHelper";
// Learn TypeScript:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class RankingItem extends cc.Component {
@property(cc.Node)
nodeBg: cc.Node = null;
@property(cc.Label)
textRank: cc.Label = null;
@property(cc.Label)
textUserName: cc.Label = null;
@property(cc.Label)
textScore: cc.Label = null;
@property(cc.Sprite)
sp_face: cc.Sprite = null;
setRankingInfo(data:PlayerData){
if(data == null){
return;
}
this.textRank.string = data.rank.toString();
this.textUserName.string = data.nickName;
this.textScore.string = data.score
if(cc.sys.platform == cc.sys.WECHAT_GAME){
WXHelper.createImage(data.avatarUrl,this.sp_face)
}
this.sp_face.node.scale = 0.4;
this.nodeBg.active = data.isSelf
}
}