1
0

Game.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const HomeApi = require("../net/HomeApi");
  2. const AlertManager = require('../utils/AlertManager');
  3. const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. levelHomePrefab: cc.Prefab,
  8. myInfoTop: cc.Node,
  9. sidebar: cc.Node,
  10. clickAddMoney: cc.Prefab,
  11. },
  12. // LIFE-CYCLE CALLBACKS:
  13. onLoad () {
  14. // 创建一个事件监听实例, 用来实现跨节点监听事件
  15. GameEvent.init();
  16. // Global.user = {
  17. // uid: 6000027,
  18. // token: "d9687ba4-66b4-48b1-a7b8-7b417d26f6d7"
  19. // };
  20. // Global.user = {
  21. // uid: 6000025,
  22. // token: "6d4a4c0f-89a6-4c04-ab0f-6ad72f9e6a24"
  23. // };
  24. cc.debug.setDisplayStats(false);
  25. //我的家园
  26. let levelHome = cc.instantiate(this.levelHomePrefab);
  27. levelHome = levelHome.getComponent('LevelHome');
  28. levelHome.init(Global.user.uid);
  29. this.levelHome = levelHome;
  30. this.levelHome.node.active = true;
  31. this._showSidebarUI();
  32. let XHeight = 1624;
  33. this.winSize = cc.view.getVisibleSize();
  34. if (this.winSize.height >= XHeight) {
  35. this.myInfoTop.height = 180;
  36. }
  37. },
  38. start () {
  39. },
  40. _showSidebarUI() {
  41. let action = cc.moveBy(0.3, cc.v2(-this.sidebar.width, 0));
  42. this.sidebar.runAction(action);
  43. },
  44. //
  45. handleQuestPopup: _.debounce((event) => {
  46. AlertManager.showQuestPopup();
  47. event.target.getChildByName("notice_point").active = false;
  48. }, 1000, true),
  49. //显示抽奖界面
  50. handleShowDraw: _.debounce((event) => {
  51. AlertManager.showDrawAlert();
  52. }, 1000, true),
  53. // update (dt) {},
  54. });