Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User jy820314's Avatar
    Join Date
    Mar 2006
    Posts
    8
    I try to use method of keyPressed

    protected void keyPressed(int keyCode) {
    }

    I find "NUM2" and " UP" binded " NUM4"and "LEFT" binded

    when I press the "NUM2" and it will generate two keyCode "NUM2" and " UP"

    How can i separate them?

    thank you!

  2. #2
    Registered User jasmitvala's Avatar
    Join Date
    Mar 2006
    Posts
    10
    jhd

    hi jy820314

    this is becuaze in the case of keyPressed whenever u r pressing the key it is for both game as well text item.

    so what u do is before decodeing u just call funcation getGameAction(keycode) it will return
    Canvas.FIRE, Canvas.LEFT,Canvas.Right.........

    so u can compare this one to prevent from returning two values.

    Regards,
    Jasmit vala
    rajputjasmit@yahoo.co.in
    [FONT=Courier New][SIZE=7]JHD[/SIZE][/FONT]

  3. #3
    Registered User bhanuj's Avatar
    Join Date
    Dec 2010
    Location
    Delhi, India
    Posts
    7
    I was using

    protected void keyPressed (int keyCode)
    {
    if(getGameAction(keyCode) == Canvas.FI(RE
    {
    //fire action
    }
    }

    to detect the selection or fire event. But when tested on phone, the FIRE event did not work

    so i used the following code

    int fireKey = getKeycode(Canvas.FIRE);
    int upKey = getKeyCode(Canvas.UP);
    int downKey = getKeyCode(Canvas.DOWN);

    protected void keyPressed (int keyCode)
    {
    if(keyCode == fireKey)
    {
    //fire action
    }
    else if (keyCode == upKey)
    {
    //up action
    }
    }

    can somebody tell what the problem is?

  4. #4
    Nokia Developer Moderator r2j7's Avatar
    Join Date
    Aug 2007
    Posts
    1,595
    Hello bhanuj,

    are you testing the FIRE key when the Canvas is on full-screen mode?

    Regards,
    r2j7

Similar Threads

  1. Problem with J2ME canvas in Nokia N90
    By hepals in forum Mobile Java General
    Replies: 5
    Last Post: 2006-05-09, 01:07
  2. Replies: 2
    Last Post: 2005-09-15, 12:54
  3. About 6230 Bt Problem
    By eerkek in forum Bluetooth Technology
    Replies: 17
    Last Post: 2005-02-08, 12:33
  4. problem scrolling canvas
    By diplm in forum Mobile Java General
    Replies: 9
    Last Post: 2004-05-26, 21:19
  5. 7650 and 3650 Canvas and FullCanvas memory
    By marcilgen in forum Mobile Java General
    Replies: 5
    Last Post: 2003-07-08, 12:24

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