slide_dir_select.ts 1.1 KB

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