8c87d0dc-c3ce-47fe-84e5-0d6a7ed5fa60.js 2.51 KB
"use strict";
cc._RF.push(module, '8c87dDcw85H/oTlDWp+1fpg', 'TouchSpecialEffComp');
// script/common/components/TouchSpecialEffComp.ts

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const simba_cc_resutils_1 = require("simba-cc-resutils");
const { ccclass, property, menu } = cc._decorator;
let TouchSpecialEffComp = /** @class */ (() => {
    let TouchSpecialEffComp = class TouchSpecialEffComp extends cc.Component {
        onLoad() {
        }
        onEnable() {
            this.node.on(cc.Node.EventType.TOUCH_START, this.callback, this, false);
            this.node.on(cc.Node.EventType.TOUCH_MOVE, this.callback, this, false);
            this.node.on(cc.Node.EventType.TOUCH_END, this.callback, this, false);
            this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.callback, this, false);
        }
        onDestroy() {
            this.node.off(cc.Node.EventType.TOUCH_END, this.callback, this);
        }
        onDisable() {
            this.node.off(cc.Node.EventType.TOUCH_END, this.callback, this);
        }
        async callback(event) {
            if (event.type == cc.Node.EventType.TOUCH_END) {
                let spNode = new cc.Node();
                spNode.name = "touchSpNode";
                let sp = spNode.addComponent(cc.Sprite);
                sp.spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes("textures/common/gift_AD", cc.SpriteFrame);
                spNode.parent = this.node;
                spNode.setPosition(this.node.convertToNodeSpaceAR(event.getLocation()));
                this.scheduleOnce(() => {
                    if (cc.isValid(spNode)) {
                        spNode.destroy();
                    }
                }, 0.5);
            }
        }
    };
    TouchSpecialEffComp = __decorate([
        ccclass,
        menu("自定义UI组件/TouchSpecialEffComp")
    ], TouchSpecialEffComp);
    return TouchSpecialEffComp;
})();
exports.default = TouchSpecialEffComp;

cc._RF.pop();