52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'f8efchVDQ5CHLD099iADo55', 'bridge.toucher');
|
||
|
|
// Scripts/zbridge/cmps/bridge.toucher.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/*******************************************************************************
|
||
|
|
*
|
||
|
|
* 全局置顶点击特效层
|
||
|
|
*
|
||
|
|
*
|
||
|
|
*
|
||
|
|
* 2021.12.10
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
"extends": cc.Component,
|
||
|
|
properties: {
|
||
|
|
spEffect: {
|
||
|
|
"default": null,
|
||
|
|
type: sp.Skeleton,
|
||
|
|
displayName: "动画"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 载入
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
// 点击监听
|
||
|
|
this.node.on("touchend", this.onTouched, this);
|
||
|
|
this.node._touchListener.setSwallowTouches(false);
|
||
|
|
|
||
|
|
// 特效初始化
|
||
|
|
nx.gui.setActive(this.spEffect, "", false);
|
||
|
|
},
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function onDestroy() {
|
||
|
|
// 点击监听解除
|
||
|
|
this.node.off("touchend", this.onTouched, this);
|
||
|
|
},
|
||
|
|
// 点击
|
||
|
|
onTouched: function onTouched(_touch) {
|
||
|
|
// 定位
|
||
|
|
var pos = _touch.getLocation();
|
||
|
|
pos = this.node.convertToNodeSpaceAR(pos);
|
||
|
|
this.spEffect.node.position = pos;
|
||
|
|
nx.gui.setActive(this.spEffect, "", true);
|
||
|
|
if (this.spEffect) {
|
||
|
|
this.spEffect.setAnimation(0, "action", false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|