Start.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { LQCollideSystem } from "./Collide/lq_collide_system/lq_collide_system";
  2. import { UIList } from "./Core/Ui/UIDef";
  3. import { UILayerNames, UILayers } from "./Core/Ui/UILayers";
  4. import { UIMgr } from "./Core/Ui/UIMgr";
  5. import bullet from "./game/bullet";
  6. import { ConfigMgr } from "./game/cfg/configMgr";
  7. import { LevelMgr } from "./levelMgr";
  8. const {ccclass, property} = cc._decorator;
  9. @ccclass
  10. export default class Start extends cc.Component {
  11. /*===========================自动绑定组件开始===========================*/
  12. /*自动生成*/
  13. @property({type:cc.Node, displayName:""})
  14. private $bulletLayer_node:cc.Node = null;
  15. /*自动生成*/
  16. @property({type:cc.Node, displayName:""})
  17. private $level_node:cc.Node = null;
  18. /*自动生成*/
  19. @property({type:cc.Label, displayName:""})
  20. private $levelTitle_lb:cc.Label = null;
  21. /*自动生成*/
  22. @property({type:cc.Node, displayName:""})
  23. private $ui_node:cc.Node = null;
  24. /*===========================自动绑定组件结束===========================*/
  25. /*===========================自动生成按钮事件开始==========================*/
  26. /*===========================自动生成按钮事件结束==========================*/
  27. @property(cc.Prefab) bulletPrefab:cc.Prefab = null;
  28. static inst: Start;
  29. constructor(){
  30. super();
  31. }
  32. protected async onLoad(): Promise<void> {
  33. Start.inst = this;
  34. // let node = new cc.Node()
  35. UIMgr.inst.setup(this.$ui_node, UILayerNames.length, UILayerNames);
  36. LQCollideSystem.is_enable = true;
  37. cc.director.getPhysicsManager().enabled = true;
  38. cc.director.getPhysicsManager().gravity = cc.v2(0, 0);
  39. await ConfigMgr.inst.init();
  40. LevelMgr.inst.parent = this.$level_node;
  41. LevelMgr.inst.title = this.$levelTitle_lb
  42. LevelMgr.inst.begin();
  43. // this.testUI();
  44. UIMgr.inst.showUI(UIList.debug);
  45. }
  46. private testUI() {
  47. UIMgr.inst.showUI(UIList.loading);
  48. UIMgr.inst.showUI(UIList.loading);
  49. setTimeout(() => {
  50. UIMgr.inst.hideUI(UIList.loading);
  51. }, 10000);
  52. }
  53. createPlayerBullet(pos: cc.Vec2){
  54. let bulletNode = cc.instantiate(this.bulletPrefab)
  55. let bulletCpt = bulletNode.getComponent(bullet);
  56. let moveCpt = bulletCpt.getMoveCpt();
  57. moveCpt.dirction = cc.v2(0,1);
  58. moveCpt.speed = 1800*2;
  59. this.$bulletLayer_node.addChild(bulletNode);
  60. bulletNode.setPosition(pos);
  61. }
  62. }