CocosCreator点击事件

编程入门 行业动态 更新时间:2024-10-20 20:44:56

CocosCreator点击<a href=https://www.elefans.com/category/jswz/34/1770959.html style=事件"/>

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点击事件

本文发布于:2024-02-06 16:55:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1750376.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   CocosCreator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!