How can I use getoneobjectatoffset with a variable instead of a class?
//Player class
private int ID;
public Player(int id)
{
ID = id;
}
public void act()
{
//move
House h = getOneIntersectingObject(House.class);
if (h != null)
{
if (h.getID() == ID) //correct house
{
//....
}
}
}
public int getID()
{
return ID;
}//House class
private int ID;
public House(int id)
{
ID = id;
}
public int getID()
{
return ID;
}//in World subclass when you create the players and houses addObject(new Player(0), 100, 100); addObject(new Player(1), 200, 200); addObject(new House(0), 200, 100); addObject(new House(1), 100, 200); //x and y values are examples