const tools = require("../script/tools");

cc.Class({
    extends: cc.Component,

    properties: {
    },

    initWithData(data, scale) {
        let sprite = this.node.children[2].getComponent(cc.Sprite)
        tools.getSpriteFrimeByUrl(data.pic_url, (sp) => {
            sprite.spriteFrame = sp
            let rect = data.rect
            this.node.setPosition((rect.x + rect.width / 2) * scale, (-rect.y - rect.height / 2) * scale)
            let height = rect.height * scale
            let width = rect.width * scale
            sprite.node.width = width
            sprite.node.height = height
            this.node.height = height
            this.node.width = width
            let node = this.node.children[0]
            node.height = height + 8
            node.width = width + 8
            node = this.node.children[1]
            node.height = height
            node.width = width
        })
    }
});
