| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
- "use strict";
- 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;
- 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 }); }
- 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; }
- 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.'); }
- function _reportPossibleCrUseOfoops(extras) {
- _reporterNs.report("oops", "../../../core/Oops", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- AudioClip = _cc.AudioClip;
- Button = _cc.Button;
- _decorator = _cc._decorator;
- game = _cc.game;
- }, function (_unresolved_2) {
- oops = _unresolved_2.oops;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "86cefAWukVE77lEwgfFdYeD", "UIButton", undefined);
- __checkObsolete__(['AudioClip', 'Button', 'EventTouch', '_decorator', 'game']);
- ({
- ccclass,
- property,
- menu
- } = _decorator);
- /**
- * 通用按钮
- * 1、防连点
- * 2、按钮点击触发音效
- */
- _export("default", UIButton = (_dec = ccclass("UIButton"), _dec2 = menu('OopsFramework/Button/UIButton (通用按钮)'), _dec3 = property({
- tooltip: "每次触发间隔"
- }), _dec4 = property({
- tooltip: "是否只触发一次"
- }), _dec5 = property({
- tooltip: "触摸音效",
- type: AudioClip
- }), _dec(_class = _dec2(_class = (_class2 = class UIButton extends Button {
- constructor(...args) {
- super(...args);
- _initializerDefineProperty(this, "interval", _descriptor, this);
- _initializerDefineProperty(this, "once", _descriptor2, this);
- _initializerDefineProperty(this, "effect", _descriptor3, this);
- // private effectIds: number[] = [];
- /** 触摸次数 */
- this._touchCount = 0;
- /** 触摸结束时间 */
- this._touchEndTime = 0;
- }
- /** 触摸结束 */
- _onTouchEnded(event) {
- // 是否只触发一次
- if (this.once) {
- if (this._touchCount > 0) {
- event.propagationStopped = true;
- return;
- }
- this._touchCount++;
- } // 防连点500毫秒出发一次事件
- if (this._touchEndTime && game.totalTime - this._touchEndTime < this.interval) {
- event.propagationStopped = true;
- } else {
- this._touchEndTime = game.totalTime;
- super._onTouchEnded(event); // 短按触摸音效
- this.playEffect();
- }
- }
- /** 短按触摸音效 */
- async playEffect() {
- if (this.effect) {
- (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
- error: Error()
- }), oops) : oops).audio.playEffect(this.effect); // const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => {
- // this.effectIds.remove(effectId);
- // });
- // if (effectId > 0) this.effectIds.push(effectId);
- }
- } // onDestroy() {
- // if (this.effect) {
- // this.effectIds.forEach(effectId => {
- // console.log(effectId);
- // oops.audio.putEffect(effectId, this.effect);
- // });
- // }
- // }
- }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "interval", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function () {
- return 500;
- }
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "once", [_dec4], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function () {
- return false;
- }
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "effect", [_dec5], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function () {
- return null;
- }
- })), _class2)) || _class) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=aab14a58f9501a142b5e754f2731ab9543e2c7dc.js.map
|