Hey, so I'm doing a project in class, and I want an enemy to follow an Actor. If someone could give me code to use or a game that has this, plz show or tell me ASAP!
public int getX(){
return xPos;
}//all this happens in enemy class
//xPos = the actual position of the enemy
//speed = the speed of the enemy
private void followActor(){
if(xPos < actor.getX()){
xPos = xPos + speed;
}else if(xPos > actor.getX()){
xPos = xPos - speed;
}
}public int getX(){
return xPos;
}