dialog_view.ts 991 B

12345678910111213141516171819202122232425262728293031323334
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('dialog_view')
  4. export class dialog_view extends Component {
  5. @property(Node) btn_sure:Node = null;
  6. @property(Node) btn_cancel:Node = null;
  7. @property(Node) lab_title:Node = null;
  8. private m_sure_call = null;
  9. private m_cancel_call = null;
  10. public show(title:string,sure_call,cancel_call){
  11. this.m_sure_call = sure_call;
  12. this.m_cancel_call = cancel_call;
  13. this.lab_title.getComponent(Label).string = title;
  14. this.btn_sure.on(Node.EventType.TOUCH_END,()=>{
  15. if(this.m_sure_call!=null){
  16. this.m_sure_call()
  17. }
  18. this.close()
  19. })
  20. this.btn_cancel.on(Node.EventType.TOUCH_END,()=>{
  21. if(this.m_cancel_call!=null){
  22. this.m_cancel_call()
  23. }
  24. this.close()
  25. })
  26. }
  27. close(){
  28. this.node.removeFromParent()
  29. }
  30. }