1
0

Init.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const weChat = require('./net/WeChat');
  2. const DWTool = require('./utils/DWTool');
  3. const Api = require('./net/Api');
  4. // const Ws = require('./net/Ws');
  5. cc.Class({
  6. extends: cc.Component,
  7. properties: {
  8. game: cc.Node,
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. onLoad() {
  12. // Ws.open();
  13. // setTimeout(() => {
  14. // Ws.emit('fuck', 111)
  15. // }, 2000)
  16. // Ws.on('getFuck', data => {
  17. // console.log(data);
  18. // })
  19. if (!CC_WECHATGAME) {
  20. Global.showLoginPage = false;
  21. Global.channel = 'LuciferChannel';
  22. Global.os = 1;
  23. Global.ver = 1;
  24. if(CC_PREVIEW) {
  25. Global.user = {
  26. uid: DWTool.getUrlParam('uid'),
  27. token: DWTool.getUrlParam('token'),
  28. nick: "Ade",
  29. avatar: "",
  30. gender: 1
  31. }
  32. } else {
  33. Global.user = {
  34. uid: 1,
  35. token: 'lucifer_test_token',
  36. nick: 'lucifer',
  37. avatar: "",
  38. gender: 1
  39. }
  40. }
  41. } else {
  42. switch (cc.sys.platform) {
  43. case cc.sys.WECHAT_GAME:
  44. Global.channel = 'weixin';
  45. break;
  46. case cc.sys.QQ_PLAY:
  47. Global.channel = 'qq';
  48. break;
  49. }
  50. }
  51. this.game.active = true;
  52. // cc.game.setFrameRate(30);//强制游戏改为30帧的方法
  53. console.log("Global: " + Global.channel);
  54. },
  55. start() {
  56. },
  57. // update (dt) {},
  58. });