Book Image

Libgdx Cross-platform Game Development Cookbook

Book Image

Libgdx Cross-platform Game Development Cookbook

Overview of this book

Table of Contents (20 chapters)
Libgdx Cross-platform Game Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating new widgets


It has been a long journey since you learned the basics of Scene2D, so you are now prepared for the fun part consisting of extending the library and generating your own content for personal projects or even for the community itself. With proper usage of the Skin class, you can perform a complete overhaul of your UI just by changing image assets. As you will know, software reuse becomes a booster in development companies so that you will not have to reinvent the wheel.

In this direction, you can easily create new widgets composed of simpler ones. Usually, the easiest way of approaching this is by extending a Table class and organizing inner widgets within it, but do not discard extending from WidgetGroup and using composition as a reliable alternative.

The possibilities for creating a new complex UI component are endless, but this recipe will cover a very simple and flexible level selector. The goal is being able to have a widget with a custom background, a level title...