I already have a way to check if the mouse is clickes, but if I click on another object, it doesnt work, since it only looks if the world is clicked.
Im trying to make so that every time I click, the character shoots, but it can only shoot one shot per click.
I already tried using the
way, but it turns out even if I put the limitant if it can shoot or not, it basically becomes a laser, since I leave it clicked, and keeps shooting.
Thanks @danpost in advance, jajaja
protected void Attack() { if(Greenfoot.mouseClicked(getWorld())) { if(canAttack) { getWorld().addObject(new Bala(getRotation()), getX(), getY()); Greenfoot.playSound("gunshotSoundEffect.mp3"); canAttack= false; } } else { canAttack= true; } }
mouse.getButton() == 1