| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /** 头像设置 */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class Head extends cc.Component {
- @property({ type: cc.Sprite, displayName: "头像" })
- img_head: cc.Sprite = null;
- @property({ type: cc.Label, displayName: '等级' })
- lbl_lv: cc.Label = null;
- private curLevel = 0;
- async start() {
- this.curLevel = gData.gameData.playerProp.gradeLevel;
- this.lbl_lv.string = 'Lv:' + this.curLevel.toString();
- this.initHead();
- }
- async initHead() {
- if (gData.wechatData.avatar != '') {
- let result = await mk.loader.loadRemote(gData.wechatData.avatar + "?aaa=aa.jpg", null);
- if (result) {
- this.img_head.spriteFrame = new cc.SpriteFrame(result);
- }
- }
- }
- protected update(dt: number): void {
- if (gData.gameData.init_head) {
- this.initHead();
- }
- if (this.curLevel != gData.gameData.playerProp.gradeLevel) {
- this.curLevel = gData.gameData.playerProp.gradeLevel;
- this.lbl_lv.string = 'Lv:' + this.curLevel.toString();
- }
- }
- clickHead() {
- mk.ui.openPanel('module/setting/setting');
- }
- }
|