Alright, this is from my Slender game. You will have to modify this where the Angel constantly checks if the Player can see it, or have the Player send the message to Angel:
Here's the code for multiple angels:
I'm going to have dinner, so I won't be able to help for the next 10 - 20 minutes. Hoped that helped
public boolean seeSlender() { //To make sure it's on the screen (I have a scrolling game, if you do, keep this, and change 275 to the value you want, if not, remove this) if (getObjectsInRange(275, Slender.class).size() == 0) return false; Slender s = (Slender)getObjectsInRange(275, Slender.class).get(0); //Or angel, if that's what you want, again, you can get rid of this and replace it with Slender s = (Slender)getWorld().getObjects(Slender).get(0) if you have multiple angels, read the code below this method int sX = s.getX(); //x Location of the slender/angel int sY = s.getY(); //y location int dir = getRotation(); //current direction turnTowards(sX, sY); //Turns it towards slender/angel int dir2 = getRotation(); //new directiong setRotation(dir); //set direction back to normal (so it looks like nothing happend) return dir - dir2 <= /*The beam's range / 2 */ && dir - dir2 >= /*The beam's range / -2*/; }
for (Slender /*or angel*/ s : getWorld().getObjects(Slender.class) { int sX = s.getX(); int sY = s.getY(); int dir = getRotation(); turnTowards(sX, sY); int dir2 = getRotation(); setRotation(dir); if (dir - dir2 <= /*Beam's range / 2*/ && dir - dir2 >= /*Beam's range / -2*/ return true; } return false;