Game Development Reference
In-Depth Information
void SetVisibility(bool value) { _isVisible =
value; };
bool GetVisibility() { return _isVisible; };
void SetPlacement(Placement p) { _placement =
p; };
Placement GetPlacement() { return _placement;
};
void SetPosition(DirectX::XMFLOAT2 pos) {
_pos = pos; };
void SetPosition(float x, float y) {
SetPosition(DirectX::XMFLOAT2(x, y)); };
DirectX::XMFLOAT2 GetPosition() { return
_pos; };
void SetCanFocus(bool canFocus) { _canFocus =
canFocus; };
bool GetCanFocus() { return _canFocus; };
};
For reference, Placement is an enumeration that we will use to position the origin of
the control, allowing for easier layout. We will only implement support for TopLeft
and Center origins; however, if you want to support other locations, just add in sup-
port to the drawing methods in your inheriting controls, as follows:
enum class Placement
{
Place_TopLeft,
Place_Center
};
Most of the methods in ControlBase are standard object-oriented ways to access
the private variables, the main ones we need to consider are Draw() ,
HandleClick() , and PointInBounds() . These methods will be implemented
in the subclass that inherits from ControlBase ; however, HandleClick and
Search WWH ::




Custom Search