You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.2 KiB
92 lines
2.2 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
//点击
|
|
import { ryw_Event } from "../../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../../FrameWork/Event/EventMgr";
|
|
import Common5 from "../../../Platform/th/Common5";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class GuizeTouch extends cc.Component {
|
|
@property(
|
|
{
|
|
type: cc.Node,
|
|
displayName: "注册触摸节点",
|
|
}
|
|
)
|
|
emitTarget:cc.Node = null
|
|
|
|
@property(
|
|
{
|
|
type: cc.Node,
|
|
displayName: "隐藏的节点",
|
|
}
|
|
)
|
|
hideTarget:cc.Node = null
|
|
|
|
|
|
@property(cc.Boolean)
|
|
isHideTarget:Boolean= true
|
|
|
|
|
|
@property(cc.Integer)
|
|
touchIndex:number = 0
|
|
|
|
|
|
onLoad () {
|
|
if(!this.emitTarget){
|
|
this.emitTarget = this.node
|
|
}
|
|
|
|
|
|
this.openTouchEvent(this.emitTarget)
|
|
|
|
}
|
|
|
|
start () {
|
|
|
|
}
|
|
|
|
|
|
openTouchEvent(node){
|
|
node.on(cc.Node.EventType.TOUCH_START,this.touchStartNode,this)
|
|
node.on(cc.Node.EventType.TOUCH_MOVE,this.touchMoveNode,this)
|
|
node.on(cc.Node.EventType.TOUCH_CANCEL,this.touchEndNode,this)
|
|
node.on(cc.Node.EventType.TOUCH_END,this.touchEndNode,this)
|
|
}
|
|
|
|
closeTouchEvent(node:cc.Node){
|
|
node.off(cc.Node.EventType.TOUCH_START,this.touchStartNode,this)
|
|
node.off(cc.Node.EventType.TOUCH_MOVE,this.touchMoveNode,this)
|
|
node.off(cc.Node.EventType.TOUCH_CANCEL,this.touchEndNode,this)
|
|
node.off(cc.Node.EventType.TOUCH_END,this.touchEndNode,this)
|
|
}
|
|
|
|
touchStartNode(event){
|
|
|
|
Common5.playEffect("点击规则");
|
|
}
|
|
|
|
|
|
touchMoveNode(event){
|
|
|
|
}
|
|
|
|
touchEndNode(event){
|
|
EventMgr.emitEvent_custom(ryw_Event.GuiZeGameBtnClick, {touchIndex: this.touchIndex});
|
|
|
|
if(this.isHideTarget){
|
|
if( this.hideTarget){
|
|
this.hideTarget.active = false
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
}
|
|
}
|
|
|