So I'm making a flappy bird project for my computer science class and one of our extensions is to create a powerup that makes you smaller. My problem is that the code will run perfectly once, it scales my image and makes it smaller, but every other time I run it the image stays the same. Every solution I try it will work once but never again.
Here is my code...
public class FlappyBird extends Actor { public void FlappyBird() { setImage("flappyBird1.png"); } public void act() { if (getOneIntersectingObject(Powerup.class) != null) { switchImage(); } } /** * */ public void switchImage() { int size = getImage().getWidth() / 2 ; int size2 = getImage().getHeight() / 2 ; GreenfootImage image = getImage(); image.scale(size, size2 ); setImage(image); } } public class Powerup extends Actor { int POWER_SPEED = -2; /** * Act - do whatever the Powerup wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { setLocation( getX() + POWER_SPEED , getY()); if (getOneIntersectingObject (FlappyBird.class) != null) { getWorld().removeObject(this); }