bag_drag_item.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { _decorator, Component, instantiate, Node, Prefab, Sprite } from 'cc';
  2. import { dai_dao_ju_item, widget_item_data } from '../../../data/data';
  3. import { gameManager } from '../gameManager';
  4. import { widget_base } from '../widget/widget_base';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('bag_drag_item')
  7. export class bag_drag_item extends Component {
  8. @property(Node) spr_select_status:Node = null;
  9. @property(Node) drag_item_parent:Node = null;
  10. @property(Prefab) drag_item_prefab:Prefab = null;
  11. private mData:dai_dao_ju_item = null;
  12. private mCallBack = null;
  13. public initView(data:dai_dao_ju_item,widget_data:widget_item_data,call){
  14. let item = instantiate(this.drag_item_prefab)
  15. item.parent = this.drag_item_parent;
  16. item.active = data.is_in_bag;
  17. let com = item.getComponent(widget_base);
  18. com.initView(widget_data,false);
  19. this.mData = data;
  20. this.mCallBack = call;
  21. this.node.on(Node.EventType.TOUCH_START,()=>{
  22. if(this.mCallBack!=null){
  23. this.mCallBack(this)
  24. }
  25. })
  26. }
  27. public getData(){
  28. return this.mData;
  29. }
  30. public onSelect(){
  31. this.spr_select_status.active = true;
  32. }
  33. public unSelect(){
  34. this.spr_select_status.active = false;
  35. }
  36. }