Skip to main content
gamedev.net
🔒 Locked

J2ME, Nokia API .getHeight() problem

Started by JohnLamock Apr 26, 2006 at 1:14 PM 4 replies 1.6k views
Original Post
JohnLamock
JohnLamock
Hello! I'm having some problems with the Nokia API. I'm using a SonyEricsson k700i device and I want to capture the Soft Keys status in a 3D game using the Mascot Capsule v3. I have tried to use the constants '-7' and '-8' for LEFT and RIGHT soft keys inside a GameCanvas class, but it don't seem to recognize the keys. So, I tried to use the Nokia API FullCanvas class, but it had some strange behavior. I have two main classes, one for the menu and another for the game itself. On the game class I used GameCanvas. When I use Nokia FullCanvas on the menu Class, the Soft Keys are recognized, but when I go to the game, the screen seems to be compressed, all the things is smaller, including the 2D images. I have googled and didn't find something that can be a solution for this. I tried to draw the objects inside a Image with the correct width and height values, but it didn't works... I ran the game with SonyEricsson W800 device too, and it recognize the soft keys only with the constants in the GameCanvas, so it seems to be a k700 exclusive problem. Someone have any ideas? Thanks in advance! [Edited by - JohnLamock on April 26, 2006 3:07:22 PM]
shmoove
shmoove
The values are -6 and -7 for the softkeys with the Nokia API (I think it's the same with the MIDP 2.0 classes but I don't really remember). -8 is the Clear key.

When you use a FullCanvas it emulates the size of a Series 60 display so you the height is 208 pixels instead of 220.

When you use a the MIDP 2.0 classes you have to call setFullScreenMode(true) to get a full screen Canvas, and you should also implement the sizeChanged() method and reset the screen height in it to make sure you have the correct value. setFullScreenMode() doesn't work immediately (in many phones the change only takes effect when the screen is updated) so getHeight() might return the value for a normal Canvas instead of a full screen one.

One last thing. Sony Ericsson phones have a weird bug where calling getGameAction() with the key code of a softkey will raise an IllegalArgumentException, so you have to watch out for that. This doesn't happen when you use a FullCanvas.

shmoove
JohnLamock
JohnLamock
Yes, you are right! It's -7 and -6, I didn't look to the code [:P]

I'll try what you said. Thanks for the answer!
JohnLamock
JohnLamock
Hi!

I didn't understand the "reset the height" part...

What do you mean? I have to call a 'reset method' or I have to put the original height value into some variable?

I looked the Canvas methods and didn't find anyone that can do this.
Sorry, I'm a bit confused.

Thank you for the help.
shmoove
shmoove
I assume you have a class variable where you store the height so you won't have to call getHeight() all the time. And you are probably setting it's value by calling getHeight() in the constructor:
int screenHeight;public TheCanvas() {  setFullMode(true);  screenHeight = getHeight();  // ...

Then you have to reset it with a new value in the sizeChanged() method:
protected void sizeChanged(int w, int h) {  screenHeight = h;  // ...


shmoove
JohnLamock
JohnLamock
Hi!

I tried to make what you said, but it didn't appear to work in the 3d part, it's still compressing the scene.

Can I capture the key with another procedure?
Without the FullCanvas Class is it impossible to capture them?

Thanks!

Topic Locked

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

Sign in to reply to this topic.