RewardRedBagPanel.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { utils } from "./Utils";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class RewardRedBagPanel extends cc.Component {
  5. private _panel: cc.Node = null;
  6. // _location: SubLocation = SubLocation.isMoreGame;
  7. onLoad() {
  8. if (utils.otherConfig && utils.otherConfig.group) {
  9. this.node.group = utils.otherConfig.group;
  10. }
  11. this._panel = this.node.getChildByName("Panel");
  12. let ratio: number = 1;
  13. if (cc.winSize.height < cc.winSize.width) {
  14. // 横屏游戏
  15. ratio = cc.winSize.width / 1920 * 0.5;
  16. } else {
  17. ratio = cc.winSize.width / 1080;
  18. }
  19. this._panel.scale = ratio;
  20. this.init();
  21. }
  22. openRedBag() {
  23. utils.SendEvent("恭喜获得红包弹窗-点击领取红包!");
  24. utils.showOpenRedBagPanel({ showType: 2 });
  25. this.hide();
  26. }
  27. public init() {
  28. utils.SendEvent("恭喜获得红包弹窗-展示成功!");
  29. }
  30. public hide() {
  31. this.node.active = false;
  32. }
  33. public onCloseBtnHandler(event: any, data: any) {
  34. this.hide();
  35. }
  36. }