FDialogTest.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import FF from "../FF";
  2. import FSprite from "../object/FSprite";
  3. import FDialogBox from "./dialog/FDialogBox";
  4. /**
  5. * 对话测试
  6. */
  7. const {ccclass, property} = cc._decorator;
  8. @ccclass
  9. export default class FDialogTest extends cc.Component {
  10. @property(cc.Prefab)
  11. mDialog: cc.Prefab = null;
  12. private ff:FF;
  13. private count = 0;
  14. /**
  15. * 对话框
  16. */
  17. private dialogBox:FDialogBox;
  18. onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){
  19. if(other.node.group == 'A'){
  20. this.count ++;
  21. let obj = other.node.getComponent(FSprite);
  22. this.ff = obj.ff;
  23. this.showButton();
  24. }
  25. }
  26. onEndContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){
  27. if(other.node.group == 'A'){
  28. this.count --;
  29. if(this.count <= 0){
  30. this.closeButton();
  31. }
  32. }
  33. }
  34. public showButton(){
  35. this.ff.control.mEventButton.node.active = true;
  36. // this.ff.mSpeedUp.node.active = false;
  37. this.ff.control.mEventButton.setCallback(()=>{
  38. this.showDialog();
  39. });
  40. }
  41. public closeButton(){
  42. this.ff.control.mEventButton.node.active = false;
  43. // this.ff.mSpeedUp.node.active = true;
  44. }
  45. public exitDialog(){
  46. }
  47. public showDialog(){
  48. let node = cc.instantiate(this.mDialog);
  49. this.ff.main.viewManage.popView(node);
  50. }
  51. }