Monday, October 22, 2007
Making a FullScreen Canvas
Updated : 10/24/2007
In this rather short tutorial, we're going to make our canvas take up the whole screen area of the phone. Open the project you created in the tutorial Basic MIDP 2.0 Game Template. Open the file clsCanvas.java then insert setFullScreenMode(true); at the end of the contructor:
That's all there is to it.
Update
As commented by our anonymous tipper, some of you might encounter a bug while calling the setFullScreenMode() function from the constructor of the GameCanvas class.
I decided to dig deeper on this and I was able to find a post at Sun's Java Forums. One poster mentioned a problem with the SonyEricsson P900 and P910 phones. You can read the whole thread here: Link to Thread.
I will try to find more information about bugs or other weird behaviors when using the setFullScreenMode() function.
In this rather short tutorial, we're going to make our canvas take up the whole screen area of the phone. Open the project you created in the tutorial Basic MIDP 2.0 Game Template. Open the file clsCanvas.java then insert setFullScreenMode(true); at the end of the contructor:
public clsCanvas(midMain m) {
super(true);
fParent = m;
setFullScreenMode(true);
}
That's all there is to it.
Update
As commented by our anonymous tipper, some of you might encounter a bug while calling the setFullScreenMode() function from the constructor of the GameCanvas class.
I decided to dig deeper on this and I was able to find a post at Sun's Java Forums. One poster mentioned a problem with the SonyEricsson P900 and P910 phones. You can read the whole thread here: Link to Thread.
I will try to find more information about bugs or other weird behaviors when using the setFullScreenMode() function.
Subscribe to:
Post Comments
(
Atom
)

email this post
Newer Post
Home

CanvasExtension myCanvas = new CanvasExtension();
myCanvas.setFullScreenMode(true)
With this I do the "setFullScreenMode" out of the Constructor Class. I read that if you call the method inside the constructor, baybe it fails.
If there was a bug, I've yet to encounter it. Maybe the bug exists on certain phone models? Or the way the canvas class was initialized? I'm unsure. But if you experience the problem I would appreciate it if you gave me a heads up.
Thanks.
Ty for the tutorials. I still find many parts useful tho i cant just copy and paste them :)
I installed latest java sdk+netbeams. And applications made in it work 5-8x slower that the java 1.4 and j2me wtk 2.1 on my s65. Why is that?
I don't think that is possible as the Mobility Pack that comes with NetBeans IS the "j2me WTK" itself. The compiler is the same one, the emulator is the same one.
I have also used the standalone and mobility pack versions of WTK 2.2, 2.5, 2.5.1 and lastly 2.5.2 to compile the same MIDlets. They all produce the same output (to my perception).
and the generated applet works in 2 colours - gray and black?
Try checking your device/platform configuration setting for the project.
And why Netbeams work so slowly?
I don't know what kind of machine you have but NetBeans does take a long time to load especially if you have so many plug-ins installed that you don't need to use and your computer doesn't have much memory left. I suggest installing only the plug-ins that you need so it doesn't eat all your machine's memory.
Also check the minimum hardware requirements of NetBeans. I first used NetBeans on a P3 Celeron 776Mhz test machine with 512MB of ram, lol, and it worked fine. The pc I'm using now is a P4 Celeron 2.4 Ghz Single Core with 512 Ram. NetBeans works fine but I can't play NFS PROStreet!!! (EA, that is so low...)
I have few newer phones but i need the compatilbility and speed. The old java run smoothly on the newer phonest at very high fps.
The compatibility of a MIDlet depends on the MIDP configuration and CLDC platform you choose before you compile you're MIDlet, and most importantly your code (specially when it comes to speed).
Like I said the Mobility pack is the same WTK so...sorry, but it just doesn't make sense that the same WTK produces different MIDlets. So I'm stupefied beyond Hogwarts...I'm afraid I can't help you on that one.
BTW, you aren't limited to using the mobility pack for your platform. You can also use the standalone Sun Java WTK from within the NetBeans IDE.
BTW the method of getting keys by getKeyStates (in both sdks) does not work on s65 and s66 correctly. (for example if you keep holding RIGHT it retuns randomly 1 and 0 on (getKeyStates & RIGHT_PRESSED) Instead i use 2 methods simulateously - getKeyStates and keyPressed/keyReleased. And it works fine on all devices that way.
Using the getKeyStates() method directly in the "IF" statement is not a good way to check for key presses since the getKeyStates() method also flushes or clears the key states. So if you call it twice in a row or in quick succession, chances are the second call would detect no keys pressed. The best way to go about it is to assign the value returned by the getKeyStates() method in a temporary int variable and use that variable in your conditional statements.
I also use the key callback events for non-standard keys like soft keys but sparingly. It's always best to make your game so that it doesn't require the user to push so many buttons on a small device. Avoid having the player push more than one button simultaneously.
One of the best mobile games I've seen so far requires only 1 button to play the game: Link to Game Info.
Frankly, I really have no experience programming for s65 and s66 (I assume both phones are Siemens?) so I have no idea what compatibility problems they have with the standard j2me. Your best bet when developing MIDlets for a particular model is to use the SDK/WTK the manufacturer provided if thay have one.
Finally, the really big issues with the portability of Game MIDlets are with fullscreen mode, key codes (pound, sharp, and soft keys) and audio support. Among minor ones are screen resolution and font sizes. Other than these quirks, standard code will work just fine.
BTW, What do you use for editing code?
I hope these insights would prove useful to you.
Good Luck!!!
http://ftp.pigwa.net/stuff/other/robbojava/Robbo_0_48a.jar
Engine is nearly finnished (there may be some hidden errors). The menu is in part-polish (poziom=level) and may be displayed baldy on phones with smaller res. (many reasons for keeping alpha stage) Now I'm working on making image fonts, but here I have some experience from other platforms (mophun) and Ill try doing it my way. When i run into some problems I'll check your tutorial of course. :) TY for great tutorials. They are easy to understand and that is the most important thing about tutorials. (and unfortunately not common) BTW I started to learn java 9 days ago :)
I see you have included graphics for 3 different resolutions. I'm applying the same technique on a game I'm working on which coincidentally is also a remake of an Atari game (2600).
Ever thought of making the sprites scroll between tiles instead of jump from tile to tile? What is the FPS on your target phone?
Thanx :)
Email me via amberlewren at gmail dot com so I can send the details and I think I can help with your game too (if you let me lol). It's very interesting as I've never played the game before. It's not available on the Atari 2600, is it?
On most newer phones with fast processors, the layer based classes works just fine. But if the processor is not fast enough (ex. N70), the layer classes will only make the game slower. So if you don't need pixel-perfect collision detection it would be better to draw the sprites and the map manually.
http://www.atarimania.com/detail_soft.php?menu=XL&SYSTEM=8&JEUX_ID=&VERSION_ID=4396&Page=1&ADV=0&OK=OK&SOFT_LIB=robbo&SFAMILLE_ID=0&TRI=SOFT_LIB&SENS=ASC
http://www.youtube.com./watch?v=LwJXgpsVAIQ
http://www.youtube.com./watch?v=2vh1xNgV1LY