cc.Class({
    extends: cc.Component,

    properties: {
        avatar: cc.Sprite,
        scoreLabel: cc.Label,
        nickLabel: cc.Label,
        rankLabel: cc.Label,
        defaultSpriteFrame: cc.SpriteFrame,
    },

    // onLoad () {},

    start() {},

    updateItem(data, i) {
        this.scoreLabel.string = data.score;
        this.nickLabel.string = data.nick;
        this.rankLabel.string = i + 1;

        cc.loader.load({
            url: data.url,
            type: 'jpg'
        }, (err, texture) => {
            if (texture) {
                this.avatar.spriteFrame = new cc.SpriteFrame(texture);
            } else {
                cc.loader.loadRes("./textures/default_avatar", cc.SpriteFrame, (err, spriteFrame) => {
                    this.avatar.spriteFrame = spriteFrame;
                });
                console.log('load avatar err:', err);
            }
        });
    },

    // update (dt) {},
})