Start.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import bullet from "../game/bullet";
  2. import { LQCollideSystem } from "../lq_collide_system/lq_collide_system";
  3. import { UIList } from "./Core/Ui/UIDef";
  4. import { UILayerNames, UILayers } from "./Core/Ui/UILayers";
  5. import { UIMgr } from "./Core/Ui/UIMgr";
  6. const {ccclass, property} = cc._decorator;
  7. @ccclass
  8. export default class Start extends cc.Component {
  9. /*===========================自动绑定组件开始===========================*/
  10. /*自动生成*/
  11. @property({type:cc.Node, displayName:""})
  12. private $bulletLayer_node:cc.Node = null;
  13. /*自动生成*/
  14. @property({type:cc.Node, displayName:""})
  15. private $ui_node:cc.Node = null;
  16. /*===========================自动绑定组件结束===========================*/
  17. /*===========================自动生成按钮事件开始==========================*/
  18. /*===========================自动生成按钮事件结束==========================*/
  19. @property(cc.Prefab) bulletPrefab:cc.Prefab = null;
  20. static inst: Start;
  21. protected onLoad(): void {
  22. Start.inst = this;
  23. // let node = new cc.Node()
  24. UIMgr.inst.setup(this.$ui_node, UILayerNames.length, UILayerNames);
  25. LQCollideSystem.is_enable = true;
  26. // UIMgr.inst.showUI(UIList.loading);
  27. // UIMgr.inst.showUI(UIList.loading);
  28. // setTimeout(()=>{
  29. // UIMgr.inst.hideUI(UIList.loading);
  30. // }, 10000)
  31. }
  32. createPlayerBullet(pos: cc.Vec2){
  33. let bulletNode = cc.instantiate(this.bulletPrefab)
  34. let bulletCpt = bulletNode.getComponent(bullet);
  35. let moveCpt = bulletCpt.getMoveCpt();
  36. moveCpt.dirction = cc.v2(0,1);
  37. moveCpt.speed = 300;
  38. this.$bulletLayer_node.addChild(bulletNode);
  39. bulletNode.setPosition(pos);
  40. }
  41. }