|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.twl.TWL
public class TWL
Convenience class for using TWL. This provides all the basics sufficient for most UIs. TWL can be used without this class if
more complex configurations are required (eg, multiple GUI instances).
This class provides a single GUI
instance with a root pane set to a widget that takes up the whole screen.
setWidget(Widget)
puts a widget into the root pane, making it easy to layout your widgets using the whole screen.
This class is relatively heavyweight because it loads a TWL theme. Generally only one instance should be created for an entire
application. Use setWidget(Widget)
and clear()
to change the widgets displayed on various application
screens.
This class implements InputProcessor
and the input methods return true if TWL handled an event. Generally you will want
to use InputMultiplexer
to avoid dispatching events that TWL handled to your application.
If an instance of this call will no longer be used, dispose()
must be called to release resources.
Field Summary | |
---|---|
Widget |
root
|
Constructor Summary | |
---|---|
TWL(SpriteBatch batch,
java.lang.String themeFile,
Files.FileType fileType)
Creates a new TWL instance with the specified theme file. |
|
TWL(SpriteBatch batch,
java.lang.String themeFile,
Files.FileType fileType,
Widget widget)
Creates a new TWL instance with the specified theme file. |
Method Summary | |
---|---|
void |
clear()
Removes all widgets from the GUI's root pane. |
void |
dispose()
|
GUI |
getGUI()
Returns the GUI instance, which is the root of the TWL UI hierachy and manages timing, inputs, etc. |
static java.net.URL |
getThemeURL(java.lang.String themeFile,
Files.FileType fileType)
Returns a URL to a theme file, which can be used with ThemeManager to create a theme for
GUI#applyTheme(ThemeManager) . |
static int |
getTwlKeyCode(int gdxKeyCode)
|
boolean |
keyDown(int keycode)
Called when a key was pressed |
boolean |
keyTyped(char character)
Called when a key was typed |
boolean |
keyUp(int keycode)
Called when a key was released |
void |
render()
Draws the TWL UI. |
boolean |
scrolled(int amount)
Called when the mouse wheel was scrolled. |
void |
setWidget(Widget widget)
Sets the widget in the GUI's root pane. |
boolean |
touchDown(int x,
int y,
int pointer,
int button)
Called when the screen was touched or a mouse button was pressed. |
boolean |
touchDragged(int x,
int y,
int pointer)
Called when a finger or the mouse was dragged. |
boolean |
touchMoved(int x,
int y)
Called when the mouse was moved without any buttons being pressed. |
boolean |
touchUp(int x,
int y,
int pointer,
int button)
Called when a finger was lifted or a mouse button was released. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Widget root
Constructor Detail |
---|
public TWL(SpriteBatch batch, java.lang.String themeFile, Files.FileType fileType, Widget widget)
public TWL(SpriteBatch batch, java.lang.String themeFile, Files.FileType fileType)
Method Detail |
---|
public GUI getGUI()
public void setWidget(Widget widget)
widget
- If null, this method is equivalent to clear()
.public void clear()
public void render()
public boolean keyDown(int keycode)
InputProcessor
keyDown
in interface InputProcessor
keycode
- one of the constants in Input.Keys
public boolean keyUp(int keycode)
InputProcessor
keyUp
in interface InputProcessor
keycode
- one of the constants in Input.Keys
public boolean keyTyped(char character)
InputProcessor
keyTyped
in interface InputProcessor
character
- The character
public boolean touchDown(int x, int y, int pointer, int button)
InputProcessor
Input.Buttons.LEFT
on
Android.
touchDown
in interface InputProcessor
x
- The x coordinate, origin is in the upper left cornery
- The y coordinate, origin is in the upper left cornerpointer
- the pointer for the event.button
- the button
public boolean touchUp(int x, int y, int pointer, int button)
InputProcessor
Input.Buttons.LEFT
on
Android.
touchUp
in interface InputProcessor
x
- The x coordinatey
- The y coordinatepointer
- the pointer for the event.button
- the button
public boolean touchDragged(int x, int y, int pointer)
InputProcessor
touchDragged
in interface InputProcessor
x
- The x coordinatey
- The y coordinatepointer
- the pointer for the event.
public boolean touchMoved(int x, int y)
InputProcessor
touchMoved
in interface InputProcessor
x
- The x coordinatey
- The y coordinate
public boolean scrolled(int amount)
InputProcessor
scrolled
in interface InputProcessor
amount
- the scroll amount, -1 or 1 depending on the direction the wheel was scrolled.
public void dispose()
public static int getTwlKeyCode(int gdxKeyCode)
public static java.net.URL getThemeURL(java.lang.String themeFile, Files.FileType fileType) throws java.net.MalformedURLException
ThemeManager
to create a theme for
GUI#applyTheme(ThemeManager)
. This is only needed if not using the TWL
class to make use of TWL.
java.net.MalformedURLException
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |