HomePanel.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { JCEngine } from "./JCEngine";
  2. import Player from "./Player";
  3. const {ccclass, property} = cc._decorator;
  4. @ccclass
  5. export default class HomePanel extends cc.Component {
  6. @property({type:cc.Node})
  7. bg:cc.Node = null;
  8. @property({type:cc.Node})
  9. theme:cc.Node = null;
  10. @property({type:cc.Node})
  11. buttons:cc.Node = null;
  12. start(){
  13. this.bg.setContentSize(cc.winSize);
  14. if (cc.winSize.width < cc.view.getDesignResolutionSize().width) {
  15. this.theme.setScale(cc.winSize.width / cc.view.getDesignResolutionSize().width);
  16. this.buttons.setScale(cc.winSize.width / cc.view.getDesignResolutionSize().width);
  17. }
  18. if (window.modeId) {
  19. this.match();
  20. } else {
  21. for (let i = 0; i < this.buttons.children.length; i++) {
  22. this.buttons.children[i].on(cc.Node.EventType.TOUCH_END, () => {
  23. window.modeId = i + 1;
  24. this.match();
  25. });
  26. }
  27. }
  28. }
  29. match() {
  30. if (window.gm.appGame) {
  31. JCEngine.boot(window.gm.serverUrl, Player);
  32. } else {
  33. // JCEngine.boot('ws://192.168.101.12:9999/birdServer', Player);
  34. JCEngine.boot(window.gm.serverUrl, Player);
  35. }
  36. this.node.destroy();
  37. window.gm.addMatchPanel();
  38. }
  39. }