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!
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!
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]
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?
Hello bhanuj,
are you testing the FIRE key when the Canvas is on full-screen mode?
Regards,
r2j7