• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Restrict Fire key press in Game Canvas

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

 
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
     
    Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic