We are trying to a button change the image of an object each time it's pressed.
The code below is what we used but the image does not change even when we call Change from the button class
without the if statement.
the following methods are in the gate class:
and this is in the button class:
can see method:
public boolean isOpen=false; public void act() { if(isOpen) { setImage("portal-open.png"); } else { setImage("portal-closed.png"); } } public void change() { if (isOpen) { isOpen=false; } else { isOpen=true; } }
public void act() { if(canSee(Player.class)) { change(); } }
public boolean canSee (Class clss) { Actor a = getOneObjectAtOffset(0,0,clss); return a!=null; }