Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User cookie_man's Avatar
    Join Date
    Apr 2007
    Location
    Israel
    Posts
    4
    Hey guys. I'm making a game on Nokia 6280 (not that it matters but it is S40 platform).
    Now the big question is how can i get acces to the soft keys, and check if they are pressed or not, while the whole game is proggramed using gamecanvas? I've used the getKeyStates() function gut when i press the soft keys, the function returns 0 on each and every 1 of them.

  2. #2
    Super Contributor shmoove's Avatar
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    getKeyStates() is only supposed to be non-zero when you are pressing one of the keys that maps to a game action, so that doesn't include the softkeys.

    If you need to access the softkeys you'll have to use keyPressed()/keyReleased(). In order to "fit in" with the rest of the game using getKeyStates, you can set boolean variables in keyPressed() and reset them in keyReleased(). Then you can check the state of the booleans in your game loop.

    shmoove

  3. #3
    Registered User cookie_man's Avatar
    Join Date
    Apr 2007
    Location
    Israel
    Posts
    4
    tnx, it worked great
    i'm making a hexagon game as a project, and had to learn j2me from 0 (ofc i knew j2se and j2ee).
    anyway big tnx

  4. #4
    Registered User ken-k's Avatar
    Join Date
    Jul 2007
    Posts
    3
    i have the same problem as cookie_man, and i tried shmoove solution to use keyPressed()/keyReleased() events but i noticed that these events don't be called.... i thought that because keyPressed()/keyReleased() are canvas events and i use GameCanvas.

    So my question is how i can use these events?

    thanks

  5. #5
    Super Contributor shmoove's Avatar
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    GameCanvas is a subclass of Canvas so that shouldn't be a problem (it inherits keyPressed()/keyReleased()).

    If you pass true as the suppressKeyEvents parameter of the GameCanvas constructor, then any key that maps to a game action won't fire keyPressed()/keyReleased() events, so check that this isn't the case.

    shmoove

  6. #6
    Registered User ken-k's Avatar
    Join Date
    Jul 2007
    Posts
    3
    ya thats it shmoove....
    it works now,
    thanks a lot

Similar Threads

  1. How to remove Soft keys
    By aravindra in forum Mobile Java General
    Replies: 6
    Last Post: 2008-03-24, 06:01
  2. Action keys rigth under the screen
    By jilko in forum Mobile Java Games
    Replies: 1
    Last Post: 2007-02-08, 13:08
  3. GameCanvas Middle Soft Key Problem
    By nnigel in forum Mobile Java General
    Replies: 5
    Last Post: 2006-06-27, 11:14
  4. Two GameCanvas
    By Viggy in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2004-11-28, 19:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved