add_task.ts 1000 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
  2. import { config } from '../../config';
  3. import { add_task_item } from './add_task_item';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('add_task')
  6. export class add_task extends Component {
  7. @property(Node) content:Node = null;
  8. @property(Node) btn_close:Node = null;
  9. @property(Prefab) item_prefab:Prefab = null;
  10. private call_back = null;
  11. public show(call){
  12. this.call_back = call;
  13. config.task_type_map.forEach((v,k)=>{
  14. let item = instantiate(this.item_prefab)
  15. item.parent = this.content;
  16. item.getComponent(add_task_item).initView(k,this.onItemClick.bind(this))
  17. })
  18. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  19. this.close()
  20. })
  21. }
  22. onItemClick(type:number){
  23. if(this.call_back!=null){
  24. this.call_back(type)
  25. }
  26. this.close()
  27. }
  28. close(){
  29. this.node.destroy()
  30. }
  31. }