[Solved] Problem with KeyPress

Put your problem here if it does not fit any of the other categories.

[Solved] Problem with KeyPress

Postby travimca » Thu Mar 06, 2008 6:10 pm

Hi,
This is Ravindran, past 2 days i am working in Android, we are devloping a small game project. In my code i wrote a code for KeyPress event but its not working. Please give me a solution for this code.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public boolean onKeyDown(final int keyCode, final KeyEvent msg)
  2.  
  3.      {
  4.  
  5.          boolean handled = false;
  6.  
  7.          
  8.  
  9.          if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
  10.  
  11.           {
  12.  
  13.                  xpos = mySpritePos.x;
  14.  
  15.                  ypos = mySpritePos.y;
  16.  
  17.                  
  18.  
  19.                  if ((xpos >= 140 && xpos <= 210) && (ypos >= 405 && ypos <= 520))
  20.  
  21.              {
  22.  
  23.                          point = point + 1;
  24.  
  25.                          this.myXDirection = HorizontalDirection.LEFT;
  26.  
  27.                          mySpritePos.x = 0;
  28.  
  29.                          mySpritePos.y = 0;
  30.  
  31.                          handled = true;
  32.  
  33.              }
  34.  
  35.          }
  36.  
  37.          
  38.  
  39.          return handled;
  40.  
  41.      }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
travimca
Freshman
Freshman
 
Posts: 2
Joined: Thu Mar 06, 2008 5:57 pm

Top

Postby plusminus » Thu Mar 06, 2008 11:54 pm

Hello travimca,

what is not working :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby travimca » Fri Mar 07, 2008 10:17 am

Hi Mr.Plusminus,
Sorry i made a mistake in that code, its working now.
Thanks for your reply.

Regards
T. Ravindran.
travimca
Freshman
Freshman
 
Posts: 2
Joined: Thu Mar 06, 2008 5:57 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests