// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { getSpriteFrimeByUrl } from "../util_PK_Game";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Player extends cc.Component {

    @property(cc.Sprite)
    icon: cc.Sprite = null;
    init(url?) {

        let defaultUrl = "http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png"
        getSpriteFrimeByUrl(url || defaultUrl, (sf: cc.SpriteFrame) => {
            this.icon.spriteFrame = sf;
            this.icon.node.scale = Math.max(this.node.width / this.icon.node.width, this.node.height / this.icon.node.height)
        })
    }

    // update (dt) {}
}
