×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Jul 2003
    Posts
    66

    GAME_D_PRESSED is fast but others are not ?

    Hello,
    In my game, I use

    public void tick() {

    int keyStates = getKeyStates();

    switch(keyStates){

    case KEY_NUM4_PRESSED: // UP LEFT
    polat.moveUpLeft();
    startX -= polat.MOVE;
    startY -= polat.MOVE;
    break;
    case KEY_NUM6_PRESSED: // UP RIGHT
    polat.moveUpRight();
    startX += polat.MOVE;
    startY -= polat.MOVE;
    break;
    case KEY_NUM2_PRESSED: // UP
    polat.moveUp();
    startY -= polat.MOVE;
    break;
    case GAME_A_PRESSED: // LEFT
    polat.moveLeft();
    startX -= polat.MOVE;
    break;
    case KEY_NUM8_PRESSED: // DOWN
    polat.moveDown();
    startY += polat.MOVE;
    break;
    case GAME_B_PRESSED: // RIGHT
    polat.moveRight();
    startX += polat.MOVE;
    break;
    case GAME_C_PRESSED: // DOWN LEFT
    polat.moveDownLeft();
    startX -= polat.MOVE;
    startY += polat.MOVE;
    break;
    case GAME_D_PRESSED: // DOWN RIGHT
    polat.moveDownRight();
    startX += polat.MOVE;
    startY += polat.MOVE;
    break;
    default:
    polat.dontMove();
    break;

    }

    }


    Here everything is fine but I have problems with the keys:
    If I press a key it reacts simultanously but the speed is slow except GAME_D_PRESSED key.

    Well GAME_D_PRESSED is fine, I don't hear any "ti-ti-ti" voices when I press this key ( # ) .

    However when I press other keys ;
    KEY_NUM4_PRESSED, KEY_NUM6_PRESSED, KEY_NUM2_PRESSED, KEY_NUM8_PRESSED
    GAME_A_PRESSED, GAME_B_PRESSED, GAME_C_PRESSED

    I hear "ti-ti-ti.." on the mobile device Nokia 6600 . This is very annoying for the player.

    GAME_D_PRESSED seems ok. but wy not others ?
    This is a very strange problem.. I can not solve it..

  2. #2
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: GAME_D_PRESSED is fast but others are not ?

    From getKeyState() documentation:

    "Gets the states of the physical game keys. Each bit in the returned integer represents a specific key on the device. A key's bit will be 1 if the key is currently down or has been pressed at least once since the last time this method was called. The bit will be 0 if the key is currently up and has not been pressed at all since the last time this method was called. This latching behavior ensures that a rapid key press and release will always be caught by the game loop, regardless of how slowly the loop runs. "

    Your switch structure will miss some key presses (as more than one of the bits might be set and therefore the value is not equal to any of your choices).
    You should probably try out a if-else-structure like
    if ((keyState & GAME_D_PRESSED) != 0) {
    //do something
    }
    else if ((keyState & GAME_A_PRESSED) != 0) {
    //do something else....
    etc.

    see the GameCanvas class documentation for more information.

    Hartti

  3. #3
    Regular Contributor
    Join Date
    Jul 2003
    Posts
    66

    Re: GAME_D_PRESSED is fast but others are not ?

    Quote Originally Posted by hartti
    You should probably try out a if-else-structure like
    if ((keyState & GAME_D_PRESSED) != 0) {
    //do something
    }
    else if ((keyState & GAME_A_PRESSED) != 0) {
    //do something else....
    etc.

    see the GameCanvas class documentation for more information.

    Hartti

    Hello Hartti,
    I tried also the if else statements, the result is the same, I still hear the voices from the device except GAME_D_PRESSED key ( # ).
    I think there is no solution for this.

    Thanks in advance

    Mehmet

Similar Threads

  1. Please test the fast builds!
    By jplauril in forum Python
    Replies: 13
    Last Post: 2005-11-20, 10:42
  2. 6680 maxing out memory too fast
    By earamsey in forum Mobile Java General
    Replies: 0
    Last Post: 2005-10-21, 22:15
  3. Fast Rendering
    By Shaikuny in forum Mobile Java General
    Replies: 0
    Last Post: 2005-07-13, 10:00
  4. fast swap window automatic update problem
    By tina_jing in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-12-01, 14:56
  5. Fast Sprite Effects on Series 40/30
    By leissler in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2003-09-29, 10:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •