Hi, currently I am a novice, coding a basic video game. The premise is a football game where the user will pass the football over the defender to the receiver, where the user will then control the movements of the wide receiver to try and score a touchdown. My issue right now, is creating the tackle() method for the defender. The purpose of the method is to try to tackle the receiver once he has the ball. However my issue is that the defender can only attempt to tackle the wide receiver once he has the ball. The check method im trying to use is checking to see if the wide receiver has set his image to "RecieverWithBall". I am currently using the following code to retrieve the objects code and then try to compare it with whether that image is "RecieverWithBall.png" or not. But it just will not work.
if(getWorld().getObjects().get(0).getImage() == new GreenfootImage("RecieverWithBall.png"){ //some code to chase the reciever }