Hey, I was wondering if someone could help me figure out how to have one actor detecting the color of another actor?
Color c = actor.getImage().getColorAt(0, 0);
Color c = actor.getImage().getColorAt(0, 0);
public class PlayerOne extends Actor
{
private GreenfootImage image;
public static int playerOneX;
public static int playerOneY;
public PlayerOne()
{
image = new GreenfootImage("playerone.png");
}
/**
* Act - do whatever the PlayerOne wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
turnMove();
playerOneX = getX();
playerOneY = getY();
}
public void turnMove()
{
if(Greenfoot.isKeyDown("left"))
{
turnTowards(0, getY());
}
if(Greenfoot.isKeyDown("right"))
{
turnTowards(600, getY());
}
if(Greenfoot.isKeyDown("up"))
{
turnTowards(getX(), 0);
}
if(Greenfoot.isKeyDown("down"))
{
turnTowards(getX(), 700);
}
move(3);
}
private void checkLevel()
{
if(isAtEdge())
{
LineOne.lineOneLevel++;
}
}
/*
*Figure out how to reference a different actor's image
*Also figure out how to define the color
*/
}