How do i have an actor detect if it is on a certain color (in the background, in other actors, etc.) and also (In a different way) detect if a color is near them
if(getColor(getX(), getY() == /*what do i put here?*/) { //the stuff i want to do }
GreenfootImage img = ...;//the image you want to check; Color color = ...;//the color you want to check; if (img.getColorAt(x, y).equals(color)) { //at the position you searched you have found the color you wanted; }
GreenfootImage img = ...;//the image you want to check;
GreenfootImage img = getImage();
GreenfootImage img = getBackground();
GreenfootImage img = Beam.img; //the image you want to check; Color color = Color.green;//the color you want to check; if (img.getColorAt(getX(), getY()).equals(color)) { canMove = false; } else { canMove = true; }
//i have this variable declared public static GreenfootImage img; //then in act i have this img = getImage();
if (color.equals(img.getColorAt(getX(), getY())))