Look at the first line closely! That is an example of how NOT to get a reference to the tank object ('getLocation' does not return a 'Tank' object; or anything close to it, for that matter).


Tank tank = new Tank(); Enemy enemy = new Enemy(); Top top = new Top(); getWorld().addObject(tank, 547, 346); tank.setRotation(180); getWorld().addObject(enemy, 49, 53); getWorld().addObject(top, enemy.getY(), enemy.getY()); top.turnTowards(tank.getX(),tank.getY());
private void turnTop() { if (getWorld().getObjects(Tank.class).isEmpty()) return; Tank tank = (Tank) getWorld().getObjects(Tank.class).get(0); turnTowards(tank.getX(), tank.getY()); }