Skip to main content
gamedev.net
🔒 Locked

[java] Forcing a repaint - used for loading screens

Started by Captain P 4 replies 2k views
Original Post
Captain P
Captain P
Hey guys, I've been working on some mobile games for the past two months, and recently I had to add loading screens to an already existing game. Not a big deal, I thought, untill I tried to implement it. I used a Canvas object to set as the current displayable object, and called it´s repaint() function. Needless to say, it didn't work: repaint() is inteded to act as a request, not a direct action. Adding a waiting time after the repaint() call didn't work either. Some hacks, including storing a Graphics object and manually calling paint(), and forcing the midlet only to continue after the paint() function had been called at least once, didn't work either. It's a MIDP 2.0, CLDC 1.1 midlet and I'm testing with the WTK22 emulator, Nokia S60 emulator and Carbide.J emulators. Since the game needs to include loading screens, it's getting a bit troublesome. Anyone here who has encountered the same problem and knows a workaround or solution?
Bimble Bob
Bimble Bob
I might be wrong but aren't MediaTrackers used for this sort of thing?
It's not a bug... it's a feature!
Captain P
Captain P
Thanks for the reply, but MediaTrackers aren't available with MIDP 2.0 midlets. Also, I´m not looking to keep track of images being loaded, but to force a screen to be redrawn.
Captain P
Captain P
Thanks. However, I already received an answer on the Nokia Developer forums, and it turns out that calling serviceRepaints() forces Java to execute all waiting repaint() calls.

The real source of my problem was something else, though: the object I was waiting for to repaint was never set as the displayable object, since Display.setCurrent() is a request function as well... talk about misleading function names there... Since I found no way to enforce those requests, I went with a different solution: installing one object as the displayable, and using that object as a manager, implementing a state machine design so I can swap the objects I want to display manually and immediatly. No need to depend on that setCurrent() function anymore. :)
straydoginc
straydoginc
Yeah. Like I said i used it for some applet issue i was having, though i found what i did with the code. :) *trash basket*

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.