MoreGamesPanel.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import GameItem from "./GameItem";
  2. import QCrossWidgetItem from "./QCrossWidgetItem";
  3. import { utils } from "./Utils";
  4. import { BannerLocation, SubLocation } from "./YZ_Constant";
  5. import PlatUtils from "./PlatUtils";
  6. import CompatibleTool from "./CompatibleTool";
  7. const { ccclass, property } = cc._decorator;
  8. const _panelSize: cc.Size[] = [cc.size(225, 1000), cc.size(506, 1000)];
  9. const _titleSize: cc.Size[] = [cc.size(111, 54), cc.size(275, 54)];
  10. const _titleBgSize: cc.Size[] = [cc.size(376, 104), cc.size(545, 104)];
  11. const _starSize: cc.Size[] = [cc.size(251, 89), cc.size(425, 89)];
  12. @ccclass
  13. export default class MoreGamesPanel extends cc.Component {
  14. _panel: cc.Node = null;
  15. _gameList: cc.Node = null;
  16. _originScale: number = 1;
  17. _gameItems: GameItem[] = [];
  18. _jumpList: any = null;
  19. _dataDirty: boolean = false;
  20. _closeBtnRight: cc.Node = null;
  21. _closeBtnLine: cc.Node = null;
  22. _star: cc.Node = null;
  23. private _items: QCrossWidgetItem[] = [];
  24. private gameItemNode: cc.Node = null;
  25. _location: SubLocation = SubLocation.isMoreGame;
  26. onLoad() {
  27. if (utils.otherConfig && utils.otherConfig.group) {
  28. this.node.group = utils.otherConfig.group;
  29. }
  30. if (!PlatUtils.IsNativeAndroid) {
  31. utils.adManager.HideBanner(BannerLocation.Home);
  32. }
  33. this._panel = this.node.getChildByName("Panel");
  34. this._gameList = this._panel.getChildByName("GameScrollView").getComponent(cc.ScrollView).content;
  35. this.gameItemNode = this._gameList.children[0];
  36. this._gameList.removeAllChildren();
  37. this.node.active = false;
  38. let ratio: number = 1;
  39. if (cc.winSize.height < cc.winSize.width) {
  40. // 横屏游戏
  41. ratio = cc.winSize.width / 1920 * 0.5;
  42. } else {
  43. ratio = cc.winSize.width / 1080;
  44. }
  45. this._panel.scale = ratio;
  46. this._originScale = this._panel.scale;
  47. }
  48. private _initWidget() {
  49. this._gameList.removeAllChildren();
  50. let totalRow = Math.floor(this._jumpList.length / 3);
  51. let totalClo = 3 * totalRow;
  52. for (let i = 0; i < totalClo; i++) {
  53. let data: any = this._jumpList[i];
  54. if (data && data.logo) {
  55. let tempNode = cc.instantiate(this.gameItemNode);
  56. let qcrossWidgetItem: QCrossWidgetItem = tempNode.getComponent("QCrossWidgetItem");
  57. qcrossWidgetItem._location = this._location;
  58. qcrossWidgetItem.init(data);
  59. this._gameList.addChild(tempNode);
  60. }
  61. }
  62. }
  63. update() {
  64. if (this._dataDirty) {
  65. this._dataDirty = false;
  66. this._updatePanel();
  67. }
  68. }
  69. _updatePanel() {
  70. utils.postRecommentShowData(this._location);
  71. this._initWidget();
  72. return;
  73. }
  74. public init(jumpList: any) {
  75. this._jumpList = jumpList;
  76. this._dataDirty = true;
  77. }
  78. public show() {
  79. this.node.active = true;
  80. }
  81. public hide() {
  82. let self = this;
  83. // this._panel.runAction(cc.sequence(cc.moveTo(0.3, CompatibleTool.position(-this._panel.getContentSize().width, 0)).easing(cc.easeQuadraticActionOut()), cc.callFunc(() => {
  84. self.node.active = false;
  85. // })));
  86. // if (!PlatUtils.IsNativeAndroid) {
  87. // utils.adManager.ShowBanner(BannerLocation.Home);
  88. // }
  89. }
  90. public onCloseBtnHandler(event: any, data: any) {
  91. this.hide();
  92. }
  93. }