So I have code that makes Crosshairs (an actor) follow my mouse. When I click it, it's supposed to set the variable 'shoot' to true. The variable shoot is defined in the Actor Methods, which contains Crosshairs and Guy. When shoot is true, Guy is supposed to create a bullet at his location. Here's all the code involving shooting, why doesn't it work?
That's about it. Nothing happens when I click on the Crosshairs.
public void shoot() //in Guy, defined in act. { if(shoot == true) { getWorld().addObject(new Bullet(), getX(), getY()); shoot = false; } }
public void setShoot() //in Crosshairs, defined in act. { if(Greenfoot.mouseClicked(this)) { shoot = true; } }
public class Methods extends Actor //Methods contains Crosshairs and Guy. { public boolean shoot;