Hello,
i have a certain number of enemies and each one of them have to attack a specific target.. I mean enemy1 to target1, enemy2 to target2, etc.. any idea of how to do this??
// create objects in world constructor
Target target1 = new Target();
Enemy enemy1 = new Enemy(target1);
Target target2 = new Target();
Enemy enemy2 = new Enemy(target2);
Target target3 = new Target();
Enemy enemy3 = new Enemy(target3);
prepare();
// add objects created into the world in the prepare method
// instance field in Enemy class
Target target;
// constructor of Enemy class
public Enemy(Target attacked)
{
target = attacked;
// any other construction code you may have
}