Start.ts 2.5 KB

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