事件"/>
CocosCreator点击事件
creator点击事件分为触摸:鼠标点击其中鼠标点击事件只有在桌面平台才会触发,触摸事件在移动平台和桌面平台都会触发,所以如果是需要发布移动平台(安卓,ios)的朋友点击事件只能监听触摸事件!
官方点击事件文档:.html
封装点击事件代码:
const {ccclass, property} = cc._decorator;
/*** 按钮事件监听*/
@ccclass
export default class UIEventListener extends cc.Component
{/*** 当鼠标在目标节点在目标节点区域中移动时,不论是否按下*/public mouseMove: (event: any) => void;/*** 当鼠标移入目标节点区域时,不论是否按下*/public mouseEnter: (event: any) => void;/*** 当鼠标移出目标节点区域时,不论是否按下*/public mouseLeave: (event: any) => void;/*** 当鼠标从按下状态松开时触发一次*/public mouseUp: (event: any) => void;/*** 按钮按钮按下超过一定时间的事件*/public mousePress:(event: any,state:boolean) => void;private pressTime:number = 0; //当前按下按钮的时间 private pressTipsTime:number = 0.6;//长按事件时间标志private isClick:boolean = false; //是否点击了按钮private touch:cc.Event;public onLoad():void{this
更多推荐
CocosCreator点击事件
发布评论