Recommended Posts

ok, java claims that it can run on anything that has a screen (phones, calculators, tv's, wristwatches etc) but I tried to run my game on several computers and every time it gave me bad version exceptions. The computers have the same JRE and JVM (Windows). So what i gotta do is to get JDK, compile every java file, then it works fine. Is that how it works or am i missing something?

Share this post

Link to post

Share on other sites

it said hereImage bg = new Image();Image is static and cant be instantiated . . .

EDIT:ok, instead of

Image bg = new Image();

i put

Image bg=createImage(room_width,room_height);

It is working now but not with the desired results. What i wanted to do is to cut down on my CPU. Originally i had a double for loop that drew 192 tiles (16 x 12) to Graphics g every step (30 times a second). My idea was to draw the tiles on an image and then draw it on the screen (which happens on average every 5 seconds). But my CPU went higher when doing it. Is it normal or am i doing something wrong?

0

Share this post

Link to post

Share on other sites

That's because you're creating an image every time you draw to the screen.

Create the image outside of the paint method, like in the constructor. If the component is resizable, instead check in the paint method to make sure the image is null or a different size than the component before creating a new one.

Share this post

Link to post

Share on other sites

And to add a bit of information still in addition to the previous posts, it is not possible to run the same Java applications on every Java runtime environment. For instance, Jave Mobile Edition is different than that of the desktop version. You have to modify your code somewhat or the thing you are trying to do is impossile all together. Also different handsets have different features, different bugs and different amount of resources.

I have written .NET, .NET Compact Framework, Symbian (Series 60), Palm OS and also J2ME applications and my experience is that .NET and .NET CF are very close to each other. In CF there are more static methods and thread handling if a bit different, but otherwise teh APIs are consistent. In Windows CE phones there aren't all the APIs or one have to resort to platform invoke (P/Invoke) to make Win32 calls, but otherwise quite similar.