Hi,
I have really been trying to come up with a way for my NPC class to figure out how far away (in pixels) class Toby is. The problem is that when I try to use the getX/getY ints, they are not static so I keep getting an error. I don't want to have to make another set of integers just for the X and Y, so could anyone tell me how I could go about doing this? Here's my code for the NPC:
thanks.
import greenfoot.*;
/**
* Base class for all npcs in the game
*
* @author (h123n)
* @version (1.0)
*/
public class NPC extends ScrollActor
{
int speed = 5;
int damage = 10;
int health = 50;
int distfromtargx = 0;
String name;
/**
* Act - do whatever the NPC wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
}
public void follow()
{
Toby.getX() - this.getX() = distfromtargx;
}
}
