cabe166a-134f-463b-8237-b3db36ce4b06.js 2.95 KB
"use strict";
cc._RF.push(module, 'cabe1ZqE09GO4I3s9s2zksG', 'UIBase');
// scripts/ui/UIBase.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UIBase = void 0;
var UIBase = /** @class */ (function (_super) {
    __extends(UIBase, _super);
    function UIBase() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.enableParam = null;
        _this._tweenobj = { progress: 0 };
        _this._usePopUpEffect = true;
        _this._useCloseEffect = true;
        _this._closing = false;
        return _this;
        // private onCloseEffectUpdate(target: { progress: number }, ratio: number) {
        //     // target.setScale(ratio, ratio, 1);
        //     this.node.setScale(target.progress, target.progress);
        //     // log(target.progress, ratio);
        // }
    }
    Object.defineProperty(UIBase.prototype, "closing", {
        /**正在关闭特效中 */
        get: function () { return this._closing; },
        enumerable: false,
        configurable: true
    });
    /**弹出特效,子类可复写 */
    UIBase.prototype.onPopUpEffect = function () {
        if (this._usePopUpEffect) {
            this.node.setScale(0.1, 0.1, 1);
            this._tweenobj.progress = 0;
            cc.tween(this._tweenobj).to(0.2, { progress: 1 }, { onUpdate: this.onEffectUpdate.bind(this), easing: 'backOut' }).call(this.onPopUpEffectFinish.bind(this)).start();
        }
    };
    UIBase.prototype.onEffectUpdate = function (target, ratio) {
        this.node.setScale(target.progress, target.progress);
    };
    UIBase.prototype.onPopUpEffectFinish = function () {
    };
    UIBase.prototype.onBeforeClose = function () {
        cc.Tween.stopAllByTarget(this._tweenobj);
    };
    UIBase.prototype.onCloseEffect = function (callBack, callBackThisObj) {
        var _this = this;
        if (this._useCloseEffect) {
            this._closing = true;
            this._tweenobj.progress = 1;
            cc.tween(this._tweenobj).to(0.2, { progress: 0 }, { onUpdate: this.onEffectUpdate.bind(this), easing: 'backIn' }).call(function () {
                _this._closing = false;
                callBack.call(callBackThisObj);
            }).start();
        }
        else {
            callBack.call(callBackThisObj);
        }
    };
    return UIBase;
}(cc.Component));
exports.UIBase = UIBase;

cc._RF.pop();