Guide.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { GuideVO } from "../../data/module/GuideData";
  2. /**
  3. * @description 新手引导
  4. * @author 邹勇
  5. */
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class Guide extends cc.Component {
  9. @property({ type: cc.Node, displayName: "显示区域" })
  10. node_display: cc.Node = null;
  11. @property({ type: cc.Node, displayName: "点击区域" })
  12. node_click: cc.Node = null;
  13. @property({ type: cc.Node, displayName: "背景" })
  14. node_bg: cc.Node = null;
  15. @property(cc.Node)
  16. node_block: cc.Node = null;
  17. @property({ type: cc.Sprite, displayName: "手指" })
  18. node_finger: cc.Sprite = null;
  19. @property({ type: cc.Sprite, displayName: "头像" })
  20. node_head: cc.Sprite = null;
  21. @property({ type: cc.Sprite, displayName: "形象" })
  22. node_person: cc.Sprite = null;
  23. private guides: GuideVO[];
  24. private crtStep: number;
  25. private crtGuide: GuideVO;
  26. onLoad() {
  27. }
  28. start() {
  29. if (gData.guideData.crtID == null) {
  30. this.node.destroy();
  31. return;
  32. }
  33. this.guides = gData.guideData.getGuidesByID(gData.guideData.crtID);
  34. this.crtStep = -1;
  35. this.nextStep();
  36. }
  37. private nextStep() {
  38. this.crtStep++;
  39. this.crtGuide = this.guides[this.crtStep];
  40. this.updateGuide();
  41. }
  42. private updateGuide() {
  43. if(this.crtGuide == null){
  44. this.close();
  45. }
  46. else{
  47. this.reset();
  48. if(this.crtGuide.display_rect != ""){
  49. let arr = this.crtGuide.display_rect.split(":");
  50. this.node_display.x = parseInt(arr[0]);
  51. this.node_display.y = parseInt(arr[1]);
  52. this.node_display.width = parseInt(arr[2]);
  53. this.node_display.height = parseInt(arr[3]);
  54. }
  55. else if(this.crtGuide.click_node != ""){
  56. }
  57. if(this.crtGuide.finger != ""){
  58. }
  59. }
  60. }
  61. clickBg() {
  62. console.log("clickBg");
  63. if (this.crtGuide && this.crtGuide.click_node == "" && this.crtGuide.display_rect == "") {
  64. this.nextStep();
  65. }
  66. }
  67. clickNodeClick() {
  68. console.log("clickNodeClick");
  69. }
  70. private close(){
  71. mk.guide.close();
  72. this.node.destroy();
  73. }
  74. }