×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    55

    HandleKeyEventL Game Engine

    Hello,

    I am developing a game engine but have come across some problems regarding key input. The problem is when you hold the joystick down the on screen sprite is not moving smoothly. I guess this is a problem with HandleKeyEventL, where the event is not getting notified frequently enough.

    The class that does the key handling is derived from CCoeControl. Does anyone know of a way to remedy this?

    Any help always appreciated

    Cheers

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    San Marcos
    Posts
    190
    I would only keep track of the KeyUp and KeyDown events.
    This way you don't have to rely on a keyboard event "Is Key down" all the time.
    Hope this helps.
    Alex

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    55

    Cheers

    Hi,

    The problem with just using EEventKeyDown and EEventKeyUp is I will only get two events every time the player presses the joy pad in a direction.

    Ideally, what I want is for the user to press the right button down and the sprite on the screen keeps moving right until the player de-presses the key. At the moment the sprite moves right until the user depresses the key, however the movement is rather jerky.

    Do you know of a way that I can ask the server if a certain key is “down”?

    Thanks

  4. #4
    Regular Contributor
    Join Date
    Mar 2003
    Location
    San Marcos
    Posts
    190
    You have to keep track of it yourself.
    Do something like this (I am using pseudo code here):

    TUint8 keys[256];

    enum {KeyOff = 0, KeyOn};

    EventHandler
    {
    if(event==KeyDown)
    {
    keys[whichkey] = KeyOn;
    }
    if(event==KeyUp)
    {
    keys[whichkey] = KeyOff;
    }
    }

    do this everytime you get a key event. Then your application should only have to check the appropriate entry in your keys[] array which should represent the current state of the key. I used this in my app, and it works like a charm!
    Hope this helps...
    Alex

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    55

    Fantastic

    Alex,

    That worked like a charm.

    I owe you one.

    Cheers

    /Steve-

Posting Permissions

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