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

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

问题描述

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

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?

推荐答案

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天全站免登陆