672f42b6-362e-48bd-92a0-e5fe7db8cdc7.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. cc._RF.push(module, '672f4K2Ni5IvZKg5f59uM3H', 'UILoadingPage');
  3. // scripts/UI/UILoadingPage.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var UIPage_1 = require("../Framework/UIPage");
  26. var Constant_1 = require("../Framework/Constant");
  27. var CocosZ_1 = require("../Framework/CocosZ");
  28. var PlatUtils_1 = require("../../common-plugin/Scripts/PlatUtils");
  29. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  30. var UILoadingPage = /** @class */ (function (_super) {
  31. __extends(UILoadingPage, _super);
  32. function UILoadingPage() {
  33. var _this = _super.call(this, Constant_1.PageName.UILoadingPage) || this;
  34. _this._loadingBar = null;
  35. _this.isValid() && _this.onLoad();
  36. return _this;
  37. }
  38. UILoadingPage.prototype.onLoad = function () {
  39. // 健康忠告
  40. var health = cc.find("health", this._page);
  41. if (health) {
  42. if (CocosZ_1.cocosz.curLanguage == "zh" && (PlatUtils_1.default.IsHuaWei || PlatUtils_1.default.IsOPPO || CocosZ_1.cocosz.isDeBug)) {
  43. health.active = true;
  44. }
  45. else {
  46. health.active = false;
  47. }
  48. }
  49. this._loadingBar = cc.find("LoadingBar", this._page).getComponent(cc.ProgressBar);
  50. };
  51. UILoadingPage.prototype.onOpen = function () {
  52. var _this = this;
  53. cc.game.on(Constant_1.default.E_GAME_LOGIC, this._onGameMassageHandler, this);
  54. // 进度默认0.01
  55. this._loadingBar.progress = 0.01;
  56. // 最低进度
  57. var r = 0.01;
  58. cc.tween(this._page)
  59. .delay(0.2)
  60. .call(function () {
  61. r += 0.01;
  62. if (r < 1) {
  63. _this._updateProgress(r);
  64. }
  65. })
  66. .union()
  67. .repeatForever()
  68. .start();
  69. };
  70. UILoadingPage.prototype.onClose = function () {
  71. cc.game.targetOff(this);
  72. };
  73. UILoadingPage.prototype._onGameMassageHandler = function (event) {
  74. this._loadingBar.node.active = true;
  75. switch (event.type) {
  76. case Constant_1.default.E_UPDATE_PROGRESS: {
  77. this._updateProgress(event.data);
  78. break;
  79. }
  80. }
  81. };
  82. UILoadingPage.prototype._updateProgress = function (pro) {
  83. if (pro > this._loadingBar.progress)
  84. this._loadingBar.progress = pro;
  85. };
  86. UILoadingPage = __decorate([
  87. ccclass
  88. ], UILoadingPage);
  89. return UILoadingPage;
  90. }(UIPage_1.default));
  91. exports.default = UILoadingPage;
  92. cc._RF.pop();