So I made a Method in my Shooter Class which adds a new object when Space is Pressed, but it creates a whole lot of bullets. I only want 1 bullet to be shot when Spacebar is pressed, but I am not sure how I can make that happen.
and then further down on the class:
1 2 3 4 | public void shoot() { getWorld().addObject( new bullet(), getX(), getY()); } |
1 2 3 4 | if (Greenfoot.isKeyDown( "space" )) { shoot(); } |