MainGame.ts 819 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { _decorator, Component, EventKeyboard, EventTouch, Input, input, instantiate, KeyCode, Node, Prefab } from 'cc';
  2. import {GameManager} from './Manager/GameManager'
  3. import { EventCustom } from './Common/EventCustom';
  4. import { Global } from './Common/Global';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('MainGame')
  7. export class MainGame extends Component {
  8. @property(Prefab)
  9. Game: Prefab = null;
  10. _game: Node;
  11. start() {
  12. }
  13. showGame() {
  14. if (this._game) {
  15. this._game.destroy();
  16. }
  17. let g = instantiate(this.Game);
  18. this.node.addChild(g);
  19. g.setPosition(0,0);
  20. //g.setScale(1.5,1.5);
  21. this._game = g;
  22. }
  23. gameEnd()
  24. {
  25. if (this._game) {
  26. this._game.destroy();
  27. }
  28. }
  29. }