c616d139-472a-4218-924f-cff65e044659.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. "use strict";
  2. cc._RF.push(module, 'c616dE5RypCGJJPz/ZeBEZZ', 'CompatibleTool');
  3. // common-plugin/Scripts/CompatibleTool.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 _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  26. /**
  27. * 兼容工具类
  28. */
  29. var CompatibleTool = /** @class */ (function (_super) {
  30. __extends(CompatibleTool, _super);
  31. function CompatibleTool() {
  32. return _super !== null && _super.apply(this, arguments) || this;
  33. }
  34. Object.defineProperty(CompatibleTool, "engineVersion", {
  35. get: function () {
  36. if (this._engineVersion > 0)
  37. return this._engineVersion;
  38. var version = cc.ENGINE_VERSION;
  39. return parseInt((version.substr(version.indexOf(".") - 1, version.length)).split(".").join(""));
  40. },
  41. enumerable: false,
  42. configurable: true
  43. });
  44. /**
  45. * 坐标接口
  46. * 2.4以上返回v3,否则返回v2
  47. * @param x
  48. * @param y
  49. */
  50. CompatibleTool.position = function (x, y) {
  51. if (this.engineVersion >= 240) {
  52. //@ts-ignore
  53. return cc.v3(x, y);
  54. }
  55. return cc.v2(x, y);
  56. };
  57. /**
  58. * 坐标接口
  59. * 2.4以上返回v3,否则返回v2
  60. * @param x
  61. * @param y
  62. */
  63. CompatibleTool.LoadRes = function (remoteUrl, callBack) {
  64. if (this.engineVersion >= 240) {
  65. var str = remoteUrl.substr(remoteUrl.lastIndexOf("."));
  66. if (str != ".jpg" && str != ".png" && str != ".jpeg") {
  67. //@ts-ignore
  68. cc.assetManager.loadRemote(remoteUrl, { ext: ".jpeg" }, callBack);
  69. //@ts-ignore
  70. cc.assetManager.loadRemote(remoteUrl, { ext: ".jpg" }, callBack);
  71. //@ts-ignore
  72. cc.assetManager.loadRemote(remoteUrl, { ext: ".png" }, callBack);
  73. }
  74. else {
  75. //@ts-ignore
  76. cc.assetManager.loadRemote(remoteUrl, callBack);
  77. }
  78. }
  79. else {
  80. var str = remoteUrl.substr(remoteUrl.lastIndexOf("."));
  81. if (str != ".jpg" && str != ".png" && str != ".jpeg") {
  82. //@ts-ignore
  83. cc.loader.load({ url: remoteUrl, type: "jpeg" }, callBack);
  84. //@ts-ignore
  85. cc.loader.load({ url: remoteUrl, type: "jpg" }, callBack);
  86. //@ts-ignore
  87. cc.loader.load({ url: remoteUrl, type: "png" }, callBack);
  88. }
  89. else {
  90. cc.loader.load(remoteUrl, callBack);
  91. }
  92. }
  93. };
  94. CompatibleTool._engineVersion = 0;
  95. CompatibleTool = __decorate([
  96. ccclass
  97. ], CompatibleTool);
  98. return CompatibleTool;
  99. }(cc.Component));
  100. exports.default = CompatibleTool;
  101. cc._RF.pop();