import { _decorator, Component, instantiate, Node, Prefab, Sprite } from 'cc'; import { dai_dao_ju_item, widget_item_data } from '../../../data/data'; import { gameManager } from '../gameManager'; import { widget_base } from '../widget/widget_base'; const { ccclass, property } = _decorator; @ccclass('bag_drag_item') export class bag_drag_item extends Component { @property(Node) spr_select_status:Node = null; @property(Node) drag_item_parent:Node = null; @property(Prefab) drag_item_prefab:Prefab = null; private mData:dai_dao_ju_item = null; private mCallBack = null; public initView(data:dai_dao_ju_item,widget_data:widget_item_data,call){ let item = instantiate(this.drag_item_prefab) item.parent = this.drag_item_parent; item.active = data.is_in_bag; let com = item.getComponent(widget_base); com.initView(widget_data,false); this.mData = data; this.mCallBack = call; this.node.on(Node.EventType.TOUCH_START,()=>{ if(this.mCallBack!=null){ this.mCallBack(this) } }) } public getData(){ return this.mData; } public onSelect(){ this.spr_select_status.active = true; } public unSelect(){ this.spr_select_status.active = false; } }