Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw Button class in libgdx

I know that libgdx has this Button class that seems so easy to use, but I wonder why the draw method is set protected?

In that case, how should I draw the button?

Scene2d Button

like image 393
Fugogugo Avatar asked Jun 02 '11 16:06

Fugogugo


3 Answers

Button is also an Actor. So you would put it on the Stage and the framework would draw it. Here is some more documentation on how this fits together.

like image 175
CaseyB Avatar answered Oct 19 '22 05:10

CaseyB


I'm writing a libgdx tutorial for beginners. This post might be useful to you: libgdx Tutorial: scene2d

like image 45
G. Steigert Avatar answered Oct 19 '22 06:10

G. Steigert


Button is an Actor, so it is used with Stage. There is official documentation for scene2d. Button is in scene2d.ui, which is a UI framework on top Stage, which is a general purpose 2D scene graph. There is no official documentation for scene2d.ui yet. You can see UITest though.

like image 3
NateS Avatar answered Oct 19 '22 06:10

NateS