Game Development Reference
In-Depth Information
4.3C ONTROLS
There are many well-known user interface elements that perform very precise functions, la-
bels, buttons, lists, these are all examples of controls that we are familiar with and use fre-
quently, the goal is to develop a working library of controls that are general enough to cover
many situations, and to make them scalable to allow us to easily develop complex or game-
specific controls.
The base control will provide the interface that any derived controls may implement to offer
their own behavior. They may also implement how they Update each frame and how they
respond to user input through the HandleInput function. Some amount of functionality is
also shared among the majority of controls such as hit testing, so it is done at the base class
level and derived controls can override it when necessary.
4.3.1 Properties
Most controls will share the same core set of features, placement, transparency, colors and
states are all properties of controls regardless of what the control's intended purpose is. We
will analyze the control class' properties and later we will do the same for its interface.
class control
{
public:
. . .
protected:
math::rectangle m_rectangle;
float m_alpha;
render::color m_foregroundColor;
render::color m_backgroundColor;
bool m_visible;
bool m_enabled;
bool m_focused;
bool m_mouseOver;
render::viewport m_viewport;
. . .
};
Search WWH ::




Custom Search