如何在 libgdx 中检测演员何时被触摸?
我在 Screen 方法的渲染方法中使用“Gdx.input.isTouched()”,以了解触摸的位置,但是当在屏幕中拖动触摸时,它还会仅在触摸演员时激活我想要的事件。
是否有侦听器知道何时触摸 Actor,但该事件不是拖动的事件,我是用精灵来做的。
I am using "Gdx.input.isTouched()" in the render method of my Screen method, to know where is touched, but when the touch is dragged in the screen, it also activates the events i want only when an actor is touched.
Is there any listener to know when an Actor is touched, but the event is not the dragged one, im doing it with sprites.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请参阅有关 LibGDX 中的 scene2d 的 wiki 页面。特别是有关输入处理的部分。
基本上,您必须在 Actor 中重写以下一个或多个方法:
See this wiki page about scene2d in LibGDX. Specifically the part about Input handling.
Basically you have to override one or more of these methods in your Actor:
libGDX
Actor
里面有一个监听器。例如,如果您想检查何时按下按钮或检查,您可以调用:
button.isPressed()
、button.isCheck()
,它返回布尔值。in libGDX
Actor
have a listener inside.Example if you want check when a button is press, or is check, you call :
button.isPressed()
,button.isCheck()
, it return boolean.我认为您必须实现以下方法之一来仅检测单次触摸而不是用户执行的移动事件。
I think you have to implement one of the following method to detect only single time touch not the move event perform by the user.
我认为当你有多个演员时,你可以在舞台上进行控制。
I think you control in Stage when you have multi-actors.