Gestures on a Table in LibGDX...
This took me longer than I care to admit.
1) Extend ActorGestureListener and implement whichever events you want
2) Set this as a listener on your table with addListener(..)
3) Use setTouchable(..) to set table to Touchable.enabled
4) Set the bounding box using setBounds(x, y, w, h)
5) Profit!
Ex:
class MyGestureListener extends ActorGestureListener {
@Override
public void fling(InputEvent event, float velocityX, float velocityY, int button) {
// Do stuff...
}
}
// Later on
Table myTable = new Table();
myTable.addListener(new MyGestureListener());
myTable.setTouchable(Touchable.enabled);
myTable.setBounds(x, y, w, h);
// Even Later.... PROFIT...
Written by Alex Hart
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#