• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Restrict Fire key press in Game Canvas

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I got a problem i would like to ask if you guys have any solution ot advice for it.... I have this game on the mobile that i am working on right now and i need the player to fire a Bullet each at a time.... But now my fire key keep's on fire at lest 2 bullet on a keypress it is like the fire key's if else statment got called 2 times.... how do i go about getting the statment to be called only once??? thanks in advance and thanks you very much... below is the code for the fire key...

 
Ramender Mall
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

IMHO, Your piece of code lefts a number of questions unanswered to appropriately allow any rancher to give a suitable suggestion.

A few of them are ->
  • What does the function sendFire() do? ( I am asking this because, if sendFire(2), means FIRE TWO BULLETS, then debugger must concentrate on keyPressR, e.g. )
  • Is it your guess that this statement gets called twice OR you have used println() etc and are sure that this is whats happening ?
  • From where does this piece of code get called? ( From Keypressed() OR from the run method() OR from the timer etc. )
  • At how many places are you setting the variable keyState? And how are you setting it? ( I mean, if you are using the BITWISE OR thing in keypressed, you need to CLEAR the bit in keyReleased() ).
  • Is this problem occuring on the emulator also or ONLY on mobile? (And which mobile in that case).


  • - Ramy..
    [ October 18, 2006: Message edited by: Ramender Mall ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic