hey guys n gals,
Im having a problem with a new menu approach i found on the net here the link to the blog its on.
basically i have a canvas that paints seperate 'screens'. the splash screen works fine but when i come to the menu screen i get the exception. however, the screen is still painted and i just cant see why this exception is produced
The canvas class:
The 'Screen' class is question:Code:protected void paint(Graphics g) { if(GameStatus.SplashScreen) { this.splashScr.drawObject(g); } else if(GameStatus.Menu) { try { this.menuScr.drawObject(g); // THIS IS THE LINE CAUSING THE PROBLEM } catch(NullPointerException e) { e.printStackTrace(); } } }
Code:public void drawObject(Graphics g) { g.drawImage(bgImg, 0, 0, 0); g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL)); String[] menuItems = { MenuItems.NEW_GAME, MenuItems.OPTIONS, MenuItems.HELP, MenuItems.ABOUT, MenuItems.EXIT }; for(int i = 0; i < menuItems.length; i++) { g.setColor(255, 255, 255); if(i == menuIndex) { g.setColor(255, 0, 0); } g.drawString(menuItems[i], 80, 130 + (i * 20), 0); } }





