1

I have developed a game but this is a serious problem I am facing. I don't have any threads in my code , but whenever I use alert

Display.setCurrent(my_alert)// my_alert has a timeout of 3000ms

then after this alert, a blank white screen appears.When the screen is pressed, then my game canvas reappears. Before setting alert, my game canvas of checkers board is set as the current display. This problems also appears after the automatic keypad lock.

This alert is vital for my game, Kindly suggest a solution.

gnat
  • 6,213
  • 108
  • 53
  • 73
E1T1
  • 139
  • 1
  • 3
  • 11

1 Answers1

2

Issues like that typically indicate missing or incorrect override of GameCanvas method showNotify():

The implementation calls showNotify() immediately prior to this Canvas being made visible on the display. Canvas subclasses may override this method to perform tasks before being shown, such as setting up animations, starting timers, etc. The default implementation of this method in class Canvas is empty.

Above method is invoked at return from Alert to prior screen. GameCanvas should somehow trigger repaint of the the screen (eg using repaint or flushGraphics methods), otherwise it will be displayed blank.

The fact that this problems also appears after the automatic keypad lock makes it even more likely that showNotify is not done right in your MIDlet.

gnat
  • 6,213
  • 108
  • 53
  • 73
  • I used repaint() and it worked, but the problem persists after keypad lock. – E1T1 Sep 06 '12 at 19:45
  • @Eda interesting. Issue with keypad lock seems to be different then. Add [logging](http://stackoverflow.com/a/12167957/839601 "eg as explained here") within `showNotify` to make sure if it's invoked or not – gnat Sep 06 '12 at 19:51
  • I added logging, and showNotify() is always invoked after the alert expires. – E1T1 Sep 07 '12 at 19:21
  • @Eda but it isn't invoked after keypad lock, or isn't invoked until user presses a key right? – gnat Sep 07 '12 at 19:22
  • The method is invoked only when the user makes a wrong move in the game. – E1T1 Sep 08 '12 at 15:03
  • @Eda interesting. This may deserve a separate question – gnat Sep 09 '12 at 06:22