Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libgdx UI that show information or text when hovered

I'm making a game using libgdx which has a lot of buttons and text fields, I was wondering if there was a Scene2d widget which the user can hover and then a message shows up, something like this.

enter image description here

like image 738
Kevin Bryan Avatar asked Jan 06 '23 03:01

Kevin Bryan


1 Answers

These are called Tooltips. There is a built-in one called TextTooltip. If you're using skin, you can create a style like this in Json:

com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: {
    default: {label: {font: myFont}, background: myBackgroundDrawable, wrapWidth: 400}
}

Tooltips actually are a type of Listener that contain a widget that it temporarily can add to the Stage. You add the tooltip to whatever widget you already have in your layout:

myButton.addListener(new TextTooltip("You can press this", skin));
like image 78
Tenfour04 Avatar answered Jan 21 '23 03:01

Tenfour04