...without getting struck by an exception if it doesn't .
I'm working on the GUI of my game and thought that rather than destroying and recreating the overlay containers used for the windows and such I would just create them once and grab the overlays after that.
The only problem is that the getOverlayElement method in OverlayManager throws an exception when you try to get an element that doesn't exist.
It's not really a big deal, but if anyone might know of a way to get around this, I would appreciate it.
Checking if an OverlayElement exists...
-
- Goblin
- Posts: 279
- Joined: Sun Feb 19, 2006 1:08 am
-
- Gnoblar
- Posts: 5
- Joined: Thu Jan 18, 2007 11:40 pm
Why not just put your getting code inside a try and catch statement? that way you can log which containers exist and which don't?
Code: Select all
try
{
//Do your grabbing code here
}
catch(...)
{
//The element doesn't exist. Log it
}