CPlusEngine UI
One thing I don’t like about many game engines is they forget to provide some basic level of UI features. Even in many of the game engines I have developed this is a lacking feature. In the CPlusEngine it now includes a few basic UI features.
Panel
Panels can have many different uses but the original intent was to create a container that could store other containers. How is this different from just using a simple entity? You could use an entity to do the exact same thing but if you wanted to add a graphic to a panel it would require many additional steps. These steps have been optimized in the panel so all you have to do is create one and provide it either a texture or file location of the texture you want to apply.
Button
Buttons are a basic UI feature that allows for the definition of three states:
- Normal - This is the current state the button is in when first created and drawn to the screen.
- Active - Is the state that shows what an active button that has either been clicked or navigated to by the keyboard.
- Over - Is the state when the mouse hovers over a button.
All states are connected to the event system and controlled by the mousemove event.
The main power of the button object is the ability to tie into the click event or even the touch event. Programmatically using the std::function template we can attach to the action event so the button can be expanded to use your game code to handle the event.
Label
Labels are an object that contain text and will use the Graphic Engine font system to draw text to the game screen. Combining a label and the button class makes for a great dynamic combo which allows your game to dynamically create its user interface.
Labels can also be used to display many different game elements like scores, timers, etc.. to the game’s GUI. Labels can be attached to just about any object that derives from the Entity class. Because of this flexibility we can use labels to really enhance the game experience.