8c87d0dc-c3ce-47fe-84e5-0d6a7ed5fa60.js
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"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();