Game Development Reference
In-Depth Information
Implementing our own user interface solution
Given that we're effectively starting from square one with our user interface
implementation, let's consider how we could go about creating our own solution.
The following sections highlight some of the issues to be aware of when developing
user interface code. One of the example projects accompanying this chapter
implements a user interface library that tries to take most of the following into account.
Using a generic approach
It really is worth taking the time to develop as generic a solution as possible when
dealing with user interface code. While implementing the frontend of a game isn't
particularly difficult to code, it is far too easy to find yourself writing UI code from
scratch for each project.
By investing in a generic approach, you can quickly put together a functional UI
for all your projects. Frontend menu systems actually tend to be little more than a
collection of buttons and labels; so why write this code multiple times? Implement
these types of controls once and you can then spend more time creating customized
controls when your game demands it.
It is recommended that you implement your UI code by creating a separate subproject,
as this will help ensure that your solution is as generic and self-contained as possible.
Marmalade makes it easy for us to create our own library modules by
using the same system the SDK uses for including its component parts.
Simply create an MKB file referencing all the source files that are part
of the library, but save it with the extension .mkf instead of .mkb . You
can then reference this module by adding the name of the MKF file
(minus the extension) to the subprojects section of the main project
MKB file. Library module directories should be placed in the same
place as the main project directory so that they can be located when
creating the project from the MKB file.
Making good use of class inheritance
A good class hierarchy can make implementing your UI a much more pleasant
experience and it is well worth taking a look at existing systems to see how they
have been constructed.
 
Search WWH ::




Custom Search