GuideManager.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import SecretaryGuide from "../prefabs/SecretaryGuide";
  8. import GameM from "./GameM";
  9. import UiM from "./UiM";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class GuideManager {
  13. //单例模式---------------------------
  14. private static _instance: GuideManager = null;
  15. public static get Instance(): GuideManager {
  16. if (!GuideManager._instance) {
  17. GuideManager._instance = new GuideManager();
  18. }
  19. return GuideManager._instance;
  20. }
  21. public secretaryGuide = null
  22. // LIFE-CYCLE CALLBACKS:
  23. // onLoad () {}
  24. public createFullGuide(parentNode: cc.Node, type: number, callback: Function) {
  25. return
  26. if (this.secretaryGuide) {
  27. this.secretaryGuide.getComponent(SecretaryGuide).initData(type, () => {
  28. callback()
  29. }, false)
  30. }
  31. else {
  32. cc.loader.loadRes("prefabs/SecretaryGuide", cc.Prefab, (err, prefab: cc.Prefab) => {
  33. if (err) {
  34. cc.error(err);
  35. return;
  36. }
  37. this.secretaryGuide = cc.instantiate(prefab)
  38. this.secretaryGuide.parent = parentNode
  39. this.secretaryGuide.getComponent(SecretaryGuide).initData(type, () => {
  40. callback()
  41. })
  42. })
  43. }
  44. }
  45. // update (dt) {}
  46. }