Game Development Reference
In-Depth Information
How to do it...
1.
A single page handles all the key, touch, timer, and rendering events:
class clGUIPage: public iObject
{
public:
clGUIPage(): FFallbackPage( NULL ) {}
virtual ~clGUIPage() {}
virtual void Update(float DeltaTime) {}
virtual void Render() {}
virtual void SetActive();
2.
Handle basic UI interaction events:
virtual bool OnKey( int Key, bool KeyState );
virtual void OnTouch( const LVector2& Pos, bool
TouchState );
3.
The page we return to when the BACK or ESC button is tapped on:
clPtr<clGUIPage> FFallbackPage;
};
4.
All the UI pages are managed by the clGUI class, which mostly delegates all events
to the currently selected page:
class clGUI: public iObject
{
public:
clGUI(): FActivePage( NULL ), FPages() {}
virtual ~clGUI() {}
void AddPage(const clPtr<clGUIPage>& P)
{
P->FGUI = this;
FPages.push_back(P);
}
void SetActivePage( const clPtr<clGUIPage>& Page )
{
if ( Page == FActivePage ) { return; }
FActivePage = Page;
}
void Update( float DeltaTime )
{
if ( FActivePage ) FActivePage->Update( DeltaTime );
}
void Render()
 
Search WWH ::




Custom Search