Some days ago i asked this: How to have multiple instances on the screen of the same sprite at the same time with javafx2 and partially solved the question elaborating the suggestion of jewelsea.
I have this obstacle now: when a key is pressed to 'fire' bullets, weapon shoot bullets as fast as a machine gun.. I would like to limit the amount of bullets that the weapon of the hero of my game can shoot..for example to decide to shoot a bullet every 0.5 secs or just when a key is pressed and not to have always a machine gun effect... In my game the part of program that controls the 'fire' effect is like this:
scene.setOnKeyTyped(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event2) {
if (event2.getCode()==KeyCode.F); { .........
Before i've tried also using setOnKeyPressed and setOnKeyReleased with the same results.. So what could i try to shoot just a bullet also keeping press the 'F' key or to limit the bullets in number? Thank you in advance and good bye!