import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import { config } from '../config';
import { ClientEvent } from '../clientEvent';
import { base_res } from './base_res';
import { bag_item_data } from '../../data/data';
const { ccclass, property } = _decorator;

@ccclass('img_item')
export class img_item extends base_res {
    @property(Node) img_icon:Node = null;
    @property(Node) lab_name:Node = null;
    public initView(type:number,data:bag_item_data,name:string,sf:SpriteFrame){
        this.setData(data)
        this.setType(type)
        this.lab_name.getComponent(Label).string = name;
        this.img_icon.getComponent(Sprite).spriteFrame = sf;
        this.node.on(Node.EventType.MOUSE_DOWN,this.onDragRes.bind(this),this)
    }
    onDragRes(){
        ClientEvent.dispatchEvent(config.Event.DragRes,this.node)
    }
}


