×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    RE: Key event not working in 7650 simulator

    Dunno 'bout the 7650, but the 7210 does not seem to recognize the arrow keys as being mapped to Canvas.UP, DOWN, etc. Turns out the Canvas.UP is the '2' phone pad key. The Canvas.DOWN is the '8' phone pad key.

    However, if you read the explicit key values instead of Canvas.UP, etc, you can actually trap the up, down, left, right arrow keys as follows, at least on the 7210 this is true:
    up = -1
    down = -2
    left = -3
    right = -4

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    47

    Key event not working in 7650 simulator

    hello there

    i program and test a game which i develop in J2ME and test it on Erisson P800 simulator.... there is character on screen whcih can be controlled by arrow keys. i fully design and test the game on P800 simulator.. then i re compile the program using SUN ONE Studio for mobile and test it on 7650 simulator.... it seems to me that the key event is not being generated in the Canvas onject... here are some parts of the code....






    package Dragon;

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.util.*;
    import java.io.*;
    import javax.microedition.io.*;

    public class SSCanvas extends Canvas
    {
    public boolean sleep;

    boolean leftKey, rightKey, upKey, downKey;


    protected void keyPressed(int keyCode)
    {
    // Get the game action from the key code
    int action = getGameAction(keyCode);

    if(action == LEFT)
    leftKey = true;
    else if(action == RIGHT)
    rightKey = true;
    else if(action == UP)
    upKey = true;
    else if(keyCode == DOWN)
    downKey = true;

    }



    protected void keyReleased(int keyCode)
    {
    // Get the game action from the key code
    int action = getGameAction(keyCode);

    if(action == LEFT)
    leftKey = false;
    else if(action == RIGHT)
    rightKey = false;
    else if(action == UP)
    upKey = false;
    else if(action == DOWN)
    downKey = false;

    }




    }



    as can be seen that on the key press event i set a variable to true. then on key release it is turn to false. in this way untill the key is pressed then the character continue to moves in that direction.



    ITS WORKING ON P800 Simulator why NOT 7650.


    Shahzad

Posting Permissions

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