aab14a58f9501a142b5e754f2731ab9543e2c7dc.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, AudioClip, Button, _decorator, game, oops, _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _crd, ccclass, property, menu, UIButton;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfoops(extras) {
  8. _reporterNs.report("oops", "../../../core/Oops", _context.meta, extras);
  9. }
  10. return {
  11. setters: [function (_unresolved_) {
  12. _reporterNs = _unresolved_;
  13. }, function (_cc) {
  14. _cclegacy = _cc.cclegacy;
  15. __checkObsolete__ = _cc.__checkObsolete__;
  16. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  17. AudioClip = _cc.AudioClip;
  18. Button = _cc.Button;
  19. _decorator = _cc._decorator;
  20. game = _cc.game;
  21. }, function (_unresolved_2) {
  22. oops = _unresolved_2.oops;
  23. }],
  24. execute: function () {
  25. _crd = true;
  26. _cclegacy._RF.push({}, "86cefAWukVE77lEwgfFdYeD", "UIButton", undefined);
  27. __checkObsolete__(['AudioClip', 'Button', 'EventTouch', '_decorator', 'game']);
  28. ({
  29. ccclass,
  30. property,
  31. menu
  32. } = _decorator);
  33. /**
  34. * 通用按钮
  35. * 1、防连点
  36. * 2、按钮点击触发音效
  37. */
  38. _export("default", UIButton = (_dec = ccclass("UIButton"), _dec2 = menu('OopsFramework/Button/UIButton (通用按钮)'), _dec3 = property({
  39. tooltip: "每次触发间隔"
  40. }), _dec4 = property({
  41. tooltip: "是否只触发一次"
  42. }), _dec5 = property({
  43. tooltip: "触摸音效",
  44. type: AudioClip
  45. }), _dec(_class = _dec2(_class = (_class2 = class UIButton extends Button {
  46. constructor(...args) {
  47. super(...args);
  48. _initializerDefineProperty(this, "interval", _descriptor, this);
  49. _initializerDefineProperty(this, "once", _descriptor2, this);
  50. _initializerDefineProperty(this, "effect", _descriptor3, this);
  51. // private effectIds: number[] = [];
  52. /** 触摸次数 */
  53. this._touchCount = 0;
  54. /** 触摸结束时间 */
  55. this._touchEndTime = 0;
  56. }
  57. /** 触摸结束 */
  58. _onTouchEnded(event) {
  59. // 是否只触发一次
  60. if (this.once) {
  61. if (this._touchCount > 0) {
  62. event.propagationStopped = true;
  63. return;
  64. }
  65. this._touchCount++;
  66. } // 防连点500毫秒出发一次事件
  67. if (this._touchEndTime && game.totalTime - this._touchEndTime < this.interval) {
  68. event.propagationStopped = true;
  69. } else {
  70. this._touchEndTime = game.totalTime;
  71. super._onTouchEnded(event); // 短按触摸音效
  72. this.playEffect();
  73. }
  74. }
  75. /** 短按触摸音效 */
  76. async playEffect() {
  77. if (this.effect) {
  78. (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
  79. error: Error()
  80. }), oops) : oops).audio.playEffect(this.effect); // const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => {
  81. // this.effectIds.remove(effectId);
  82. // });
  83. // if (effectId > 0) this.effectIds.push(effectId);
  84. }
  85. } // onDestroy() {
  86. // if (this.effect) {
  87. // this.effectIds.forEach(effectId => {
  88. // console.log(effectId);
  89. // oops.audio.putEffect(effectId, this.effect);
  90. // });
  91. // }
  92. // }
  93. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "interval", [_dec3], {
  94. configurable: true,
  95. enumerable: true,
  96. writable: true,
  97. initializer: function () {
  98. return 500;
  99. }
  100. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "once", [_dec4], {
  101. configurable: true,
  102. enumerable: true,
  103. writable: true,
  104. initializer: function () {
  105. return false;
  106. }
  107. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "effect", [_dec5], {
  108. configurable: true,
  109. enumerable: true,
  110. writable: true,
  111. initializer: function () {
  112. return null;
  113. }
  114. })), _class2)) || _class) || _class));
  115. _cclegacy._RF.pop();
  116. _crd = false;
  117. }
  118. };
  119. });
  120. //# sourceMappingURL=aab14a58f9501a142b5e754f2731ab9543e2c7dc.js.map