Game Development Reference
In-Depth Information
{
if (apOrientation->m_Width > apOrientation->m_Height)
{
// Switch to landscape
}
else
{
// Switch to portrait
}
}
return 0;
}
// Call this somewhere in our set up code
s3eSurfaceRegister(S3E_SURFACE_SCREENSIZE, (s3eCallback)
OnOrientationChanged, NULL);
It is highly recommended, if you are supporting both portrait and landscape in
your game, that you define specific layouts of your controls for each orientation
and switch between them when the device is rotated. Trying to accommodate both
orientations with a single layout is possible but tends to yield uninspiring results
in both orientations, so make the most of the available screen space by providing
custom layouts for each.
Adding template functionality
Consistency is an important part of the user interface design. We expect controls of
a similar type to look the same. If they don't, the design starts to look sloppy and
unprofessional. It's therefore useful to be able to provide a way of defining certain
aspects of our UI once, and Template definitions allow us to do just that.
A relatively easy way of implementing templates is to be able to copy the settings
of one UI control into another. We can create a control that will never actually be
displayed, but will act as a template for other controls. When creating a new control
we can copy all member settings from the template and then proceed to make
changes to the settings so that the control displays whatever we need it to.
One way of implementing this is to add a virtual method to the element class, which
is given a pointer to the template control. Each class can override this method to set
its member variables based on the values contained in the template. By calling the
virtual method in the parent class, we can copy all member variable settings from the
template right down to the base element class.
 
Search WWH ::




Custom Search