PopComponet.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import { Options } from "../GameUI/PopManger";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export default class PopComponet extends cc.Component {
  11. Options: Options = null
  12. MyPopBronTime: number = 0
  13. onLoad() {
  14. this.MyPopBronTime = cc.sys.now()
  15. let Mask = this.node.getChildByName("Mask")
  16. Mask.on(cc.Node.EventType.TOUCH_START, (event: cc.Event.EventTouch) => {
  17. event.stopPropagation()
  18. if (cc.sys.now() - this.MyPopBronTime>500) {
  19. this.Surpclose()
  20. }
  21. })
  22. }
  23. Surpclose() {
  24. this.node.destroy()
  25. }
  26. //带有 Widget 的节点 经过动画之后 会不正确的显示
  27. OpenAniOver() {
  28. this.scheduleOnce(() => {
  29. this.getComponentsInChildren((cc.Widget)).forEach((e) => {
  30. e.updateAlignment()
  31. })
  32. }, 0)
  33. }
  34. }