I want to perform some action when user press up and down button. HOw can i handle the events regarding it ?
I want to perform some action when user press up and down button. HOw can i handle the events regarding it ?
In ur canvas you have to override the method
protected void keyPressed(int keyCode) {
switch(getGameAction(keyCode)){
case Canvas.UP:
//do something
break;
case Canvas.DOWN:
//do something
break;
}
}
honest_success
please explain yourself a little bit more.
:Ruben
Hi,
Honest are you talking about the up and down key pressed..
You can move like this -
protected void keyPressed(int keyCode)
{
if(keyCode == -1)
{
// Up key action ..you wana
}
else if(keyCode == -2)
{
// Down key action ..you wana
}
}
As mahesh has suggested thats also a way to do that..However the getGameAction(keycode) has a tendency to give the incorrect results...sometimes..
Thanks,
Thanks with Regards,
R a j - The K e r n e l
Join Delhi-NCR Nokia Developer's Community,