/******************************************************************************* * * 全局置顶点击特效层 * * * * 2021.12.10 ******************************************************************************/ cc.Class( { extends: cc.Component, properties: { spEffect: { default: null, type: sp.Skeleton, displayName: "动画" }, }, // 载入 onLoad: function() { // 点击监听 this.node.on( "touchend", this.onTouched, this ); this.node._touchListener.setSwallowTouches( false ); // 特效初始化 nx.gui.setActive( this.spEffect, "", false ); }, // 销毁 onDestroy: function() { // 点击监听解除 this.node.off( "touchend", this.onTouched, this ); }, // 点击 onTouched: function( _touch ) { // 定位 let 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 ); } }, } );