鼠标悬停 - libgdx [英] Mouse hover - libgdx

查看:30
本文介绍了鼠标悬停 - libgdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

libgdx 中是否有任何侦听器可以让我检测到鼠标悬停而不是按下只是悬停.在场景 2D 的按钮类中,您有 2 个方法 isOver 和 isPressed 但它们做同样的事情......还有其他人有这个问题吗?还有其他方法可以检测鼠标悬停在演员身上吗?

Is there any listener in libgdx that would allow me to detect just mouse hover not pressed just hover. In the button class of scene 2D you have 2 methods isOver and isPressed but they do the same thing ... Anyone else having this problem? Is there another way to detect mouse hover over actor?

推荐答案

这里有 ClickListener 可以附加到 Actor 并提供如下事件:

There's the ClickListener which can be attached to an Actor and it offers events like the following ones:

public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor)
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)

enter 事件基本意味着鼠标开始悬停在actor 上,exit 意味着它离开"了actor 的区域.它还有一个 clicked 事件,您可以使用它来执行一些操作.

The enter event basiscally means that the mouse started hovering over the actor, exit means it "left" the area of the actor. It also has a clicked event which you can use to execute some action in the end.

这篇关于鼠标悬停 - libgdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆