I am making a game where you can spend points to get powerups. I've got it to actually work where you can collect points and spend them on various items, but I'm having a problem where if I have too many points and I buy a low costing upgrade, it purchases the same item for as many it can buy even if I tap the key once on my keyboard. I've listed the coding below to show my problem. My problem is if I have 20 exp points, when I click the "S" key once to buy a ray shield it buys two of them instead of just one. Is there anyway to tell it to only buy one item at a time?
public void rayShield() { if(Greenfoot.isKeyDown("s")) { if(exp >= 10) { exp = exp - 10; getWorld().addObject(new RayShieldArwing(), getX(), getY() - 40); } } }